Skip to content

Commit 7a33828

Browse files
authored
Merge pull request #19 from 0xeb/rename-mcpapp-to-fastmcp
Rename McpApp to FastMCP for Python parity
2 parents f677365 + af6f163 commit 7a33828

6 files changed

Lines changed: 83 additions & 83 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ fastmcpp is a C++ port of the Python [fastmcp](https://github.com/jlowin/fastmcp
2626
- Resources and prompts support.
2727
- Resource templates with URI pattern matching.
2828
- JSON Schema validation.
29-
- McpApp high-level application class.
29+
- FastMCP high-level application class.
3030
- ProxyApp for backend server proxying.
3131
- ServerSession for bidirectional communication, sampling, and server-initiated notifications.
3232
- Built-in middleware: Logging, Timing, Caching, RateLimiting, ErrorHandling.

include/fastmcpp/app.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace fastmcpp
1919
struct MountedApp
2020
{
2121
std::string prefix; // Prefix for tools/prompts (e.g., "weather")
22-
class McpApp* app; // Non-owning pointer to mounted app
22+
class FastMCP* app; // Non-owning pointer to mounted app
2323
};
2424

2525
/// Proxy-mounted app with prefix (proxy mode)
@@ -31,15 +31,15 @@ struct ProxyMountedApp
3131

3232
/// MCP Application - bundles server metadata with managers
3333
///
34-
/// Similar to Python's FastMCP class. Provides:
34+
/// Equivalent to Python's FastMCP class. Provides:
3535
/// - Server metadata (name, version, icons, etc.)
3636
/// - Tool, Resource, and Prompt managers
3737
/// - App mounting support with prefixes
3838
///
3939
/// Usage:
4040
/// ```cpp
41-
/// McpApp main_app("MainApp", "1.0");
42-
/// McpApp weather_app("WeatherApp", "1.0");
41+
/// FastMCP main_app("MainApp", "1.0");
42+
/// FastMCP weather_app("WeatherApp", "1.0");
4343
///
4444
/// // Register tools on sub-app
4545
/// weather_app.tools().register_tool(get_forecast_tool);
@@ -49,13 +49,13 @@ struct ProxyMountedApp
4949
///
5050
/// // Tools accessible as "weather_get_forecast"
5151
/// ```
52-
class McpApp
52+
class FastMCP
5353
{
5454
public:
5555
/// Construct app with metadata
56-
explicit McpApp(std::string name = "fastmcpp_app", std::string version = "1.0.0",
57-
std::optional<std::string> website_url = std::nullopt,
58-
std::optional<std::vector<Icon>> icons = std::nullopt);
56+
explicit FastMCP(std::string name = "fastmcpp_app", std::string version = "1.0.0",
57+
std::optional<std::string> website_url = std::nullopt,
58+
std::optional<std::vector<Icon>> icons = std::nullopt);
5959

6060
// Metadata accessors
6161
const std::string& name() const
@@ -125,7 +125,7 @@ class McpApp
125125
/// @param app The app to mount (must outlive this app in direct mode)
126126
/// @param prefix Optional prefix (empty string = no prefix)
127127
/// @param as_proxy If true, mount in proxy mode (uses MCP handler for communication)
128-
void mount(McpApp& app, const std::string& prefix = "", bool as_proxy = false);
128+
void mount(FastMCP& app, const std::string& prefix = "", bool as_proxy = false);
129129

130130
/// Get list of directly mounted apps
131131
const std::vector<MountedApp>& mounted() const

include/fastmcpp/mcp/handler.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace fastmcpp
1616
{
17-
class McpApp; // Forward declaration
17+
class FastMCP; // Forward declaration
1818
class ProxyApp; // Forward declaration
1919
} // namespace fastmcpp
2020

@@ -58,9 +58,9 @@ make_mcp_handler(const std::string& server_name, const std::string& version,
5858
const resources::ResourceManager& resources, const prompts::PromptManager& prompts,
5959
const std::unordered_map<std::string, std::string>& descriptions = {});
6060

61-
// MCP handler from McpApp - supports mounted apps with aggregation
61+
// MCP handler from FastMCP - supports mounted apps with aggregation
6262
// Uses app's aggregated lists and routing for mounted sub-apps
63-
std::function<fastmcpp::Json(const fastmcpp::Json&)> make_mcp_handler(const McpApp& app);
63+
std::function<fastmcpp::Json(const fastmcpp::Json&)> make_mcp_handler(const FastMCP& app);
6464

6565
// MCP handler from ProxyApp - supports proxying to backend server
6666
// Uses app's aggregated lists (local + remote) and routing
@@ -73,11 +73,11 @@ using SessionAccessor = std::function<std::shared_ptr<server::ServerSession>(con
7373
/// The session_accessor callback is used to get ServerSession for sampling requests.
7474
/// Session ID is extracted from params._meta.session_id (injected by SSE server).
7575
std::function<fastmcpp::Json(const fastmcpp::Json&)>
76-
make_mcp_handler_with_sampling(const McpApp& app, SessionAccessor session_accessor);
76+
make_mcp_handler_with_sampling(const FastMCP& app, SessionAccessor session_accessor);
7777

78-
/// Convenience: create handler from McpApp + SseServerWrapper
78+
/// Convenience: create handler from FastMCP + SseServerWrapper
7979
/// Uses the SSE server's get_session() method as the session accessor.
8080
std::function<fastmcpp::Json(const fastmcpp::Json&)>
81-
make_mcp_handler_with_sampling(const McpApp& app, server::SseServerWrapper& sse_server);
81+
make_mcp_handler_with_sampling(const FastMCP& app, server::SseServerWrapper& sse_server);
8282

8383
} // namespace fastmcpp::mcp

src/app.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
namespace fastmcpp
99
{
1010

11-
McpApp::McpApp(std::string name, std::string version, std::optional<std::string> website_url,
12-
std::optional<std::vector<Icon>> icons)
11+
FastMCP::FastMCP(std::string name, std::string version, std::optional<std::string> website_url,
12+
std::optional<std::vector<Icon>> icons)
1313
: server_(std::move(name), std::move(version), std::move(website_url), std::move(icons))
1414
{
1515
}
1616

17-
void McpApp::mount(McpApp& app, const std::string& prefix, bool as_proxy)
17+
void FastMCP::mount(FastMCP& app, const std::string& prefix, bool as_proxy)
1818
{
1919
if (as_proxy)
2020
{
@@ -40,22 +40,22 @@ void McpApp::mount(McpApp& app, const std::string& prefix, bool as_proxy)
4040
// Prefix Utilities
4141
// =========================================================================
4242

43-
std::string McpApp::add_prefix(const std::string& name, const std::string& prefix)
43+
std::string FastMCP::add_prefix(const std::string& name, const std::string& prefix)
4444
{
4545
if (prefix.empty())
4646
return name;
4747
return prefix + "_" + name;
4848
}
4949

50-
std::pair<std::string, std::string> McpApp::strip_prefix(const std::string& name)
50+
std::pair<std::string, std::string> FastMCP::strip_prefix(const std::string& name)
5151
{
5252
auto pos = name.find('_');
5353
if (pos == std::string::npos)
5454
return {"", name};
5555
return {name.substr(0, pos), name.substr(pos + 1)};
5656
}
5757

58-
std::string McpApp::add_resource_prefix(const std::string& uri, const std::string& prefix)
58+
std::string FastMCP::add_resource_prefix(const std::string& uri, const std::string& prefix)
5959
{
6060
if (prefix.empty())
6161
return uri;
@@ -73,7 +73,7 @@ std::string McpApp::add_resource_prefix(const std::string& uri, const std::strin
7373
return scheme + "://" + prefix + "/" + path;
7474
}
7575

76-
std::string McpApp::strip_resource_prefix(const std::string& uri, const std::string& prefix)
76+
std::string FastMCP::strip_resource_prefix(const std::string& uri, const std::string& prefix)
7777
{
7878
if (prefix.empty())
7979
return uri;
@@ -93,7 +93,7 @@ std::string McpApp::strip_resource_prefix(const std::string& uri, const std::str
9393
return uri;
9494
}
9595

96-
bool McpApp::has_resource_prefix(const std::string& uri, const std::string& prefix)
96+
bool FastMCP::has_resource_prefix(const std::string& uri, const std::string& prefix)
9797
{
9898
if (prefix.empty())
9999
return true; // Empty prefix matches everything
@@ -112,7 +112,7 @@ bool McpApp::has_resource_prefix(const std::string& uri, const std::string& pref
112112
// Aggregated Lists
113113
// =========================================================================
114114

115-
std::vector<std::pair<std::string, const tools::Tool*>> McpApp::list_all_tools() const
115+
std::vector<std::pair<std::string, const tools::Tool*>> FastMCP::list_all_tools() const
116116
{
117117
std::vector<std::pair<std::string, const tools::Tool*>> result;
118118

@@ -153,7 +153,7 @@ std::vector<std::pair<std::string, const tools::Tool*>> McpApp::list_all_tools()
153153
return result;
154154
}
155155

156-
std::vector<client::ToolInfo> McpApp::list_all_tools_info() const
156+
std::vector<client::ToolInfo> FastMCP::list_all_tools_info() const
157157
{
158158
std::vector<client::ToolInfo> result;
159159

@@ -200,7 +200,7 @@ std::vector<client::ToolInfo> McpApp::list_all_tools_info() const
200200
return result;
201201
}
202202

203-
std::vector<resources::Resource> McpApp::list_all_resources() const
203+
std::vector<resources::Resource> FastMCP::list_all_resources() const
204204
{
205205
std::vector<resources::Resource> result;
206206

@@ -247,7 +247,7 @@ std::vector<resources::Resource> McpApp::list_all_resources() const
247247
return result;
248248
}
249249

250-
std::vector<resources::ResourceTemplate> McpApp::list_all_templates() const
250+
std::vector<resources::ResourceTemplate> FastMCP::list_all_templates() const
251251
{
252252
std::vector<resources::ResourceTemplate> result;
253253

@@ -293,7 +293,7 @@ std::vector<resources::ResourceTemplate> McpApp::list_all_templates() const
293293
return result;
294294
}
295295

296-
std::vector<std::pair<std::string, const prompts::Prompt*>> McpApp::list_all_prompts() const
296+
std::vector<std::pair<std::string, const prompts::Prompt*>> FastMCP::list_all_prompts() const
297297
{
298298
std::vector<std::pair<std::string, const prompts::Prompt*>> result;
299299

@@ -335,7 +335,7 @@ std::vector<std::pair<std::string, const prompts::Prompt*>> McpApp::list_all_pro
335335
// Routing
336336
// =========================================================================
337337

338-
Json McpApp::invoke_tool(const std::string& name, const Json& args) const
338+
Json FastMCP::invoke_tool(const std::string& name, const Json& args) const
339339
{
340340
// Try local tools first
341341
try
@@ -437,7 +437,7 @@ Json McpApp::invoke_tool(const std::string& name, const Json& args) const
437437
throw NotFoundError("tool not found: " + name);
438438
}
439439

440-
resources::ResourceContent McpApp::read_resource(const std::string& uri, const Json& params) const
440+
resources::ResourceContent FastMCP::read_resource(const std::string& uri, const Json& params) const
441441
{
442442
// Try local resources first
443443
try
@@ -562,8 +562,8 @@ resources::ResourceContent McpApp::read_resource(const std::string& uri, const J
562562
throw NotFoundError("resource not found: " + uri);
563563
}
564564

565-
std::vector<prompts::PromptMessage> McpApp::get_prompt(const std::string& name,
566-
const Json& args) const
565+
std::vector<prompts::PromptMessage> FastMCP::get_prompt(const std::string& name,
566+
const Json& args) const
567567
{
568568
// Try local prompts first
569569
try

src/mcp/handler.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -885,8 +885,8 @@ make_mcp_handler(const std::string& server_name, const std::string& version,
885885
};
886886
}
887887

888-
// McpApp handler - supports mounted apps with aggregation
889-
std::function<fastmcpp::Json(const fastmcpp::Json&)> make_mcp_handler(const McpApp& app)
888+
// FastMCP handler - supports mounted apps with aggregation
889+
std::function<fastmcpp::Json(const fastmcpp::Json&)> make_mcp_handler(const FastMCP& app)
890890
{
891891
return [&app](const fastmcpp::Json& message) -> fastmcpp::Json
892892
{
@@ -1525,7 +1525,7 @@ static std::string extract_session_id(const fastmcpp::Json& params)
15251525
}
15261526

15271527
std::function<fastmcpp::Json(const fastmcpp::Json&)>
1528-
make_mcp_handler_with_sampling(const McpApp& app, SessionAccessor session_accessor)
1528+
make_mcp_handler_with_sampling(const FastMCP& app, SessionAccessor session_accessor)
15291529
{
15301530
return [&app, session_accessor](const fastmcpp::Json& message) -> fastmcpp::Json
15311531
{
@@ -1831,7 +1831,7 @@ make_mcp_handler_with_sampling(const McpApp& app, SessionAccessor session_access
18311831
}
18321832

18331833
std::function<fastmcpp::Json(const fastmcpp::Json&)>
1834-
make_mcp_handler_with_sampling(const McpApp& app, server::SseServerWrapper& sse_server)
1834+
make_mcp_handler_with_sampling(const FastMCP& app, server::SseServerWrapper& sse_server)
18351835
{
18361836
return make_mcp_handler_with_sampling(app, [&sse_server](const std::string& session_id)
18371837
{ return sse_server.get_session(session_id); });

0 commit comments

Comments
 (0)