category
mcp_server_application
Common predicates for MCP servers: tool/prompt/resource descriptor conversion, completion request handling, schema derivation from info/2 and mode/2 directives, auto-dispatch, canonical complete-result terms, curly-term predicates, and MCP Apps (_meta.ui) metadata.
logtalk_load(mcp_server(loader))staticPublic predicates
tool_descriptors_to_json/3
Converts a list of tool(Name, Functor, Arity) descriptors into MCP JSON tool definitions, deriving titles, descriptions and input schemas from the application object’s info/2 and mode/2 directives.
statictool_descriptors_to_json(ToolDescriptors,Application,JsonTools)tool_descriptors_to_json(+list,+object_identifier,-list) - oneProtected predicates
prompt_descriptors_to_json/2
Converts prompt descriptors (3-arg or 4-arg) into MCP JSON prompt definitions.
staticprompt_descriptors_to_json(PromptDescriptors,JsonPrompts)prompt_descriptors_to_json(+list,-list) - oneresource_descriptors_to_json/3
Converts resource descriptors (4-arg or 5-arg) into MCP JSON resource definitions. When the application defines resource_ui_meta/2, attaches _meta.ui (MCP Apps).
staticresource_descriptors_to_json(Descriptors,Application,Resources)resource_descriptors_to_json(+list,+object_identifier,-list) - oneresource_template_descriptors_to_json/2
Converts resource template descriptors (4-arg or 5-arg) into MCP JSON resource template definitions. No partial list is returned when a descriptor is invalid.
staticresource_template_descriptors_to_json(Descriptors,ResourceTemplates)resource_template_descriptors_to_json(+list,-list) - one_or_errorURITemplate:domain_error(uri_template,URITemplate)application_resource_template_uri/2
Checks that a concrete resource URI matches the literal segments of one of the application resource templates. Full RFC 6570 expression validation and authorization remain application responsibilities.
staticapplication_resource_template_uri(Application,URI)application_resource_template_uri(+object_identifier,+atom) - zero_or_onecompletion_request/5
Validates and normalizes completion request parameters. The normalized reference is prompt(Name) or resource(URI), the argument is a Name-PartialValue pair, and the context is a list of prior argument pairs.
staticcompletion_request(Application,Params,Reference,Argument,Context)completion_request(+object_identifier,+compound,-compound,-pair,-list) - zero_or_onecompletion_result_to_json/2
Validates and converts a completion result to its MCP JSON curly-term representation.
staticcompletion_result_to_json(Result,JsonCompletion)completion_result_to_json(+compound,-compound) - zero_or_oneauto_dispatch_tool/5
Auto-dispatches a tool call by calling the predicate on the application, collecting output-mode arguments, and returning structured output with a backwards-compatible text content item.
staticauto_dispatch_tool(Application,Functor,Arity,ToolArguments,Result)auto_dispatch_tool(+object_identifier,+atom,+integer,+compound,-compound) - onetry_tool_call_3/7
Tries tool_call/3. Falls back to auto-dispatch on failure.
statictry_tool_call_3(Application,ToolName,Functor,Arity,ArgPairs,ToolArguments,Result)try_tool_call_3(+object_identifier,+atom,+atom,+integer,+list,+compound,-compound) - onetool_input_schema/4
Derives a JSON Schema curly-term for tool input arguments from the application object’s info/2 and mode/2 directives. Used by Streamable HTTP x-mcp-header / Mcp-Param-* validation when the application does not define input_schema/2.
statictool_input_schema(Application,Functor,Arity,InputSchema)tool_input_schema(+object_identifier,+atom,+integer,-compound) - onetool_output_schema/4
Derives a JSON Schema curly-term for tool output arguments from the application object’s info/2 and mode/2 directives.
statictool_output_schema(Application,Functor,Arity,OutputSchema)tool_output_schema(+object_identifier,+atom,+integer,-compound) - oneformat_content_items/2
Converts canonical content item terms into MCP JSON content array elements.
staticformat_content_items(Items,Elements)format_content_items(+list,-list) - oneformat_prompt_messages/2
Converts message(Role, text(Text)) terms into MCP JSON prompt message objects.
staticformat_prompt_messages(Messages,JsonMessages)format_prompt_messages(+list,-list) - oneformat_resource_contents/2
Converts text_content/3 and blob_content/3 terms into MCP JSON resource content objects.
staticformat_resource_contents(Contents,JsonContents)format_resource_contents(+list,-list) - onehas_pair/3
Looks up a Key-Value pair inside a curly-term.
statichas_pair(Curly,Key,Value)has_pair(+compound,+atom,?term) - zero_or_onecurly_to_pairs/2
Converts a curly-term to a list of Key-Value pairs.
staticcurly_to_pairs(Curly,Pairs)curly_to_pairs(+compound,-list) - onepairs_to_curly/2
Converts a list of Key-Value pairs to a curly-term.
staticpairs_to_curly(Pairs,Curly)pairs_to_curly(+list,-compound) - onePrivate predicates
(no local declarations; see entity ancestors if any)
Operators
(none)