@@ -57,6 +57,38 @@ struct ProxyMountedApp
5757class FastMCP
5858{
5959 public:
60+ struct ToolOptions
61+ {
62+ std::optional<std::string> title;
63+ std::optional<std::string> description;
64+ std::optional<std::vector<Icon>> icons;
65+ std::vector<std::string> exclude_args;
66+ TaskSupport task_support{TaskSupport::Forbidden};
67+ Json output_schema{Json::object ()};
68+ };
69+
70+ struct PromptOptions
71+ {
72+ std::optional<std::string> description;
73+ std::optional<Json> meta;
74+ std::vector<prompts::PromptArgument> arguments;
75+ TaskSupport task_support{TaskSupport::Forbidden};
76+ };
77+
78+ struct ResourceOptions
79+ {
80+ std::optional<std::string> description;
81+ std::optional<std::string> mime_type;
82+ TaskSupport task_support{TaskSupport::Forbidden};
83+ };
84+
85+ struct ResourceTemplateOptions
86+ {
87+ std::optional<std::string> description;
88+ std::optional<std::string> mime_type;
89+ TaskSupport task_support{TaskSupport::Forbidden};
90+ };
91+
6092 // / Construct app with metadata
6193 explicit FastMCP (std::string name = " fastmcpp_app" , std::string version = " 1.0.0" ,
6294 std::optional<std::string> website_url = std::nullopt ,
@@ -117,6 +149,49 @@ class FastMCP
117149 return server_;
118150 }
119151
152+ // =========================================================================
153+ // Ergonomic registration helpers (Python FastMCP decorator-style analogs)
154+ // =========================================================================
155+
156+ // / Register a tool using either a full JSON Schema or a "simple" param map
157+ // / (e.g., {"a":"number","b":"integer"}).
158+ FastMCP& tool (std::string name, const Json& input_schema_or_simple, tools::Tool::Fn fn,
159+ ToolOptions options);
160+ FastMCP& tool (std::string name, const Json& input_schema_or_simple, tools::Tool::Fn fn);
161+
162+ // / Register a zero-argument tool (input schema defaults to {}).
163+ FastMCP& tool (std::string name, tools::Tool::Fn fn, ToolOptions options);
164+ FastMCP& tool (std::string name, tools::Tool::Fn fn);
165+
166+ // / Register a prompt generator (equivalent to Python's @server.prompt).
167+ FastMCP& prompt (std::string name,
168+ std::function<std::vector<prompts::PromptMessage>(const Json&)> generator,
169+ PromptOptions options);
170+ FastMCP& prompt (std::string name,
171+ std::function<std::vector<prompts::PromptMessage>(const Json&)> generator);
172+
173+ // / Register a template-backed prompt (legacy Prompt template string).
174+ FastMCP& prompt_template (std::string name, std::string template_string, PromptOptions options);
175+ FastMCP& prompt_template (std::string name, std::string template_string);
176+
177+ // / Register a concrete resource (equivalent to Python's @server.resource for fixed URIs).
178+ FastMCP& resource (std::string uri, std::string name,
179+ std::function<resources::ResourceContent(const Json&)> provider,
180+ ResourceOptions options);
181+ FastMCP& resource (std::string uri, std::string name,
182+ std::function<resources::ResourceContent(const Json&)> provider);
183+
184+ // / Register a resource template (equivalent to Python's @server.resource for templated URIs).
185+ // / If parameters_schema_or_simple is empty, parameters are derived from the URI template.
186+ FastMCP&
187+ resource_template (std::string uri_template, std::string name,
188+ std::function<resources::ResourceContent(const Json& params)> provider,
189+ const Json& parameters_schema_or_simple, ResourceTemplateOptions options);
190+ FastMCP&
191+ resource_template (std::string uri_template, std::string name,
192+ std::function<resources::ResourceContent(const Json& params)> provider,
193+ const Json& parameters_schema_or_simple = Json::object());
194+
120195 // =========================================================================
121196 // App Mounting
122197 // =========================================================================
0 commit comments