MCPcopy Create free account
hub / github.com/ClickHouse/ai-sdk-cpp / get_city_attractions

Function get_city_attractions

examples/tool_calling_basic.cpp:43–65  ·  view source on GitHub ↗

Example tool function: Get city attractions

Source from the content-addressed store, hash-verified

41
42// Example tool function: Get city attractions
43ai::JsonValue get_city_attractions(const ai::JsonValue& args,
44 const ai::ToolExecutionContext& context) {
45 std::string city = args["city"].get<std::string>();
46
47 ai::JsonValue attractions;
48 if (city == "San Francisco") {
49 attractions = {"Golden Gate Bridge", "Alcatraz Island", "Fisherman's Wharf",
50 "Lombard Street"};
51 } else if (city == "New York") {
52 attractions = {"Statue of Liberty", "Central Park", "Times Square",
53 "Brooklyn Bridge"};
54 } else if (city == "Paris") {
55 attractions = {"Eiffel Tower", "Louvre Museum", "Notre-Dame Cathedral",
56 "Arc de Triomphe"};
57 } else {
58 attractions = {"Downtown area", "Local parks", "Historical sites"};
59 }
60
61 ai::JsonValue result = {{"city", city}, {"attractions", attractions}};
62
63 std::cout << "🏛️ Attractions tool called for: " << city << std::endl;
64 return result;
65}
66
67int main() {
68 std::cout << "AI SDK C++ - Basic Tool Calling Example\n";

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected