@@ -22,16 +22,22 @@ void ToolInjectionMiddleware::add_prompt_tools(const prompts::PromptManager& pm)
2222
2323 Json prompt_list = Json::array ();
2424 for (const auto & [name, prompt] : prompts) {
25- prompt_list. push_back ( Json{
25+ Json prompt_obj = {
2626 {" name" , name},
27- {" template" , prompt.template_string ()}
28- });
27+ {" description" , prompt.template_string ()},
28+ {" arguments" , Json::array ()},
29+ {" messages" , Json::array ({
30+ Json{{" role" , " user" },
31+ {" content" , Json::array ({
32+ Json{{" type" , " text" }, {" text" , prompt.template_string ()}}
33+ })}}
34+ })}
35+ };
36+ prompt_list.push_back (prompt_obj);
2937 }
3038
3139 return Json{
32- {" content" , Json::array ({
33- Json{{" type" , " text" }, {" text" , prompt_list.dump (2 )}}
34- })}
40+ {" prompts" , prompt_list}
3541 };
3642 }
3743 );
@@ -59,10 +65,18 @@ void ToolInjectionMiddleware::add_prompt_tools(const prompts::PromptManager& pm)
5965 Context ctx (resources::ResourceManager (), pm);
6066 std::string rendered = ctx.get_prompt (name, arguments);
6167
68+ Json messages = Json::array ({
69+ Json{{" role" , " user" },
70+ {" content" , Json::array ({
71+ Json{{" type" , " text" }, {" text" , rendered}}
72+ })}}
73+ });
74+
6275 return Json{
63- {" content" , Json::array ({
64- Json{{" type" , " text" }, {" text" , rendered}}
65- })}
76+ {" name" , name},
77+ {" description" , nullptr },
78+ {" arguments" , Json::array ()},
79+ {" messages" , messages}
6680 };
6781 }
6882 );
@@ -79,22 +93,24 @@ void ToolInjectionMiddleware::add_resource_tools(const resources::ResourceManage
7993 {" required" , Json::array ()}
8094 },
8195 [&rm](const Json& /* args*/ ) -> Json {
96+ // Preserve full metadata in MCP-like structure
8297 Context ctx (rm, prompts::PromptManager ());
8398 auto resources = ctx.list_resources ();
8499
85100 Json resource_list = Json::array ();
86101 for (const auto & res : resources) {
87102 resource_list.push_back (Json{
88103 {" uri" , res.id .value },
89- {" kind" , resources::to_string (res.kind )},
104+ {" name" , res.id .value },
105+ {" description" , nullptr },
106+ {" mimeType" , res.metadata .value (" mimeType" , " text/plain" )},
107+ {" annotations" , res.metadata .value (" annotations" , Json::object ())},
90108 {" metadata" , res.metadata }
91109 });
92110 }
93111
94112 return Json{
95- {" content" , Json::array ({
96- Json{{" type" , " text" }, {" text" , resource_list.dump (2 )}}
97- })}
113+ {" resources" , resource_list}
98114 };
99115 }
100116 );
@@ -116,10 +132,16 @@ void ToolInjectionMiddleware::add_resource_tools(const resources::ResourceManage
116132 Context ctx (rm, prompts::PromptManager ());
117133 std::string content = ctx.read_resource (uri);
118134
135+ Json contents = Json::array ({
136+ Json{
137+ {" uri" , uri},
138+ {" mimeType" , " text/plain" },
139+ {" text" , content}
140+ }
141+ });
142+
119143 return Json{
120- {" content" , Json::array ({
121- Json{{" type" , " text" }, {" text" , content}}
122- })}
144+ {" contents" , contents}
123145 };
124146 }
125147 );
0 commit comments