Last active
May 7, 2025 15:44
-
-
Save bhelx/168d0d81ffb1a2063c9a3496c4089780 to your computer and use it in GitHub Desktop.
mcp.run xtp schema yaml. Download xtp first: https://docs.xtp.dylibso.com/. Run the command: `xtp plugin init --schema-file https://gist.githubusercontent.com/bhelx/168d0d81ffb1a2063c9a3496c4089780/raw/5c07bab05433cb207931f8f8d10785e5f791b8a9/mcp.run.schema.yaml` and replace with the current raw url if this has been updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# yaml-language-server: $schema=https://xtp.dylibso.com/assets/wasm/schema.json | |
# download xtp command: https://docs.xtp.dylibso.com/ | |
# replace with current raw gist url: | |
# xtp plugin init --schema-file https://gist.githubusercontent.com/bhelx/168d0d81ffb1a2063c9a3496c4089780/raw/5c07bab05433cb207931f8f8d10785e5f791b8a9/mcp.run.schema.yaml | |
version: v1-draft | |
exports: | |
describe: | |
description: | | |
Called by mcpx to understand how and why to use this tool. | |
Note: Your servlet configs will not be set when this function is called, | |
so do not rely on config in this function | |
output: | |
description: The tools' descriptions, supporting multiple tools from a single servlet. | |
$ref: "#/components/schemas/ListToolsResult" | |
contentType: application/json | |
codeSamples: | |
- lang: typescript | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
return { | |
tools: [{ | |
name: "greet", | |
description: "A very simple tool to provide a greeting", | |
inputSchema: { | |
type: "object", | |
properties: { | |
name: { | |
type: "string", | |
description: "the name of the person to greet", | |
}, | |
}, | |
required: ["name"], | |
}, | |
}] | |
} | |
- lang: rust | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
Ok(types::ListToolsResult { | |
tools: vec![ | |
types::ToolDescription { | |
name: "greet".to_string(), | |
description: "A very simple tool to provide a greeting".to_string(), | |
input_schema: serde_json::json!({ | |
"type": "object", | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "the name of the person to greet" | |
} | |
}, | |
"required": ["name"] | |
}) | |
.as_object() | |
.unwrap() | |
.clone(), | |
} | |
], | |
}) | |
- lang: go | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
return ListToolsResult{ | |
Tools: []ToolDescription{{ | |
Name: "greet", | |
Description: "A very simple tool to provide a greeting", | |
InputSchema: map[string]interface{}{ | |
"type": "object", | |
"properties": map[string]interface{}{ | |
"name": map[string]interface{}{ | |
"type": "string", | |
"description": "the name of the person to greet", | |
}, | |
}, | |
"required": []string{"name"}, | |
}, | |
}}, | |
}, nil | |
- lang: python | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
return ListToolsResult([ | |
ToolDescription( | |
name="greet", | |
description="A very simple tool to provide a greeting", | |
inputSchema={ | |
"type": "object", | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "the name of the person to greet", | |
}, | |
}, | |
"required": ["name"], | |
}, | |
) | |
]) | |
- lang: c++ | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
return pdk::ListToolsResult{ | |
.tools = { | |
pdk::ToolDescription{ | |
.inputSchema = jsoncons::json::parse(R"( | |
{ | |
"type": "object", | |
"properties": { | |
"name": { | |
"type": "string", | |
"description": "the name of the person to greet" | |
} | |
}, | |
"required": ["name"] | |
} | |
)"), | |
.description = "A very simple tool to provide a greeting", | |
.name = "greet" | |
} | |
} | |
}; | |
call: | |
description: | | |
Called when the tool is invoked. | |
If you support multiple tools, you must switch on the input.params.name to detect which tool is being called. | |
input: | |
description: The incoming tool request from the LLM | |
$ref: "#/components/schemas/CallToolRequest" | |
contentType: application/json | |
output: | |
description: The servlet's response to the given tool call | |
$ref: "#/components/schemas/CallToolResult" | |
contentType: application/json | |
codeSamples: | |
- lang: typescript | |
label: A simple greeting tool that greets someone by name | |
source: | | |
const name = input.params.arguments?.name | |
if (!name) { | |
throw new Error("Argument `name` must be provided") | |
} | |
return { | |
content: [ | |
{ | |
type: ContentType.Text, | |
text: `Hello ${name}!!!` | |
} | |
] | |
} | |
- lang: rust | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
let name = _input | |
.params | |
.arguments | |
.as_ref() | |
.and_then(|args| args.get("name")) | |
.and_then(|name| name.as_str()) | |
.ok_or_else(|| Error::msg("Argument `name` must be provided"))?; | |
Ok(types::CallToolResult { | |
content: vec![types::Content { | |
r#type: types::ContentType::Text, | |
text: Some(format!("Hello {}!!!", name)), | |
annotations: None, | |
data: None, | |
mime_type: None, | |
}], | |
is_error: None, | |
}) | |
- lang: go | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
args := input.Params.Arguments | |
if args == nil { | |
return CallToolResult{}, errors.New("Arguments must be provided") | |
} | |
argsMap := args.(map[string]interface{}) | |
text := "Hello " + argsMap["name"].(string) + "!!!" | |
return CallToolResult{ | |
Content: []Content{{ | |
Type: ContentTypeText, | |
Text: &text, | |
}}, | |
}, nil | |
- lang: python | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
name = input.params.arguments['name'] | |
return CallToolResult( | |
content=[ | |
Content( | |
text=f'Hello, {name}', | |
type=ContentType.Text, | |
) | |
], | |
) | |
- lang: c++ | |
label: Description of a simple greeting tool that greets someone by name | |
source: | | |
if (!input.params.arguments) { | |
return pdk::CallToolResult { | |
.content = { | |
{.text = "No arguments", .type = pdk::ContentType::text}, | |
}, | |
.isError = true | |
}; | |
} | |
const auto name = (*input.params.arguments)["name"].as<std::string>(); | |
auto text = std::string("Hello ") + name + "!!!"; | |
return pdk::CallToolResult { | |
.content = { | |
{.text = std::move(text), .type = pdk::ContentType::text}, | |
}, | |
}; | |
components: | |
schemas: | |
ListToolsResult: | |
description: Provides one or more descriptions of the tools available in this servlet. | |
properties: | |
tools: | |
description: The list of ToolDescription objects provided by this servlet. | |
type: array | |
items: | |
$ref: "#/components/schemas/ToolDescription" | |
required: | |
- tools | |
ToolDescription: | |
description: Describes the capabilities and expected paramters of the tool function | |
properties: | |
name: | |
description: The name of the tool. It should match the plugin / binding name. | |
type: string | |
description: | |
description: A description of the tool | |
type: string | |
inputSchema: | |
description: The JSON schema describing the argument input | |
type: object | |
required: | |
- name | |
- description | |
- inputSchema | |
CallToolRequest: | |
description: Used by the client to invoke a tool provided by the server. | |
properties: | |
method: | |
type: string | |
params: | |
$ref: "#/components/schemas/Params" | |
required: | |
- params | |
Params: | |
properties: | |
arguments: | |
type: object | |
name: | |
type: string | |
required: | |
- name | |
CallToolResult: | |
description: |- | |
The server's response to a tool call. | |
Any errors that originate from the tool SHOULD be reported inside the result | |
object, with `isError` set to true, _not_ as an MCP protocol-level error | |
response. Otherwise, the LLM would not be able to see that an error occurred | |
and self-correct. | |
However, any errors in _finding_ the tool, an error indicating that the | |
server does not support tool calls, or any other exceptional conditions, | |
should be reported as an MCP error response. | |
properties: | |
content: | |
type: array | |
items: | |
$ref: "#/components/schemas/Content" | |
isError: | |
description: |- | |
Whether the tool call ended in an error. | |
If not set, this is assumed to be false (the call was successful). | |
type: boolean | |
required: | |
- content | |
Content: | |
description: | | |
A content response. | |
For text content set type to ContentType.Text and set the `text` property | |
For image content set type to ContentType.Image and set the `data` and `mimeType` properties | |
properties: | |
annotations: | |
$ref: "#/components/schemas/TextAnnotation" | |
text: | |
description: The text content of the message. | |
type: string | |
data: | |
description: The base64-encoded image data. | |
format: byte | |
type: string | |
mimeType: | |
description: The MIME type of the image. Different providers may support different image types. | |
type: string | |
type: | |
$ref: "#/components/schemas/ContentType" | |
required: | |
- type | |
TextAnnotation: | |
description: A text annotation | |
properties: | |
audience: | |
description: |- | |
Describes who the intended customer of this object or data is. | |
It can include multiple entries to indicate content useful for multiple audiences (e.g., `["user", "assistant"]`). | |
items: | |
$ref: '#/components/schemas/Role' | |
type: array | |
priority: | |
description: |- | |
Describes how important this data is for operating the server. | |
A value of 1 means "most important," and indicates that the data is | |
effectively required, while 0 means "least important," and indicates that | |
the data is entirely optional. | |
type: number | |
format: float | |
ContentType: | |
enum: | |
- text | |
- image | |
- resource | |
Role: | |
description: The sender or recipient of messages and data in a conversation. | |
enum: | |
- assistant | |
- user | |
TextResourceContents: | |
properties: | |
mimeType: | |
description: The MIME type of this resource, if known. | |
type: string | |
text: | |
description: The text of the item. This must only be set if the item can actually be represented as text (not binary data). | |
type: string | |
uri: | |
description: The URI of this resource. | |
type: string | |
required: | |
- text | |
- uri | |
BlobResourceContents: | |
properties: | |
blob: | |
description: A base64-encoded string representing the binary data of the item. | |
format: byte | |
type: string | |
mimeType: | |
description: The MIME type of this resource, if known. | |
type: string | |
uri: | |
description: The URI of this resource. | |
type: string | |
required: | |
- blob | |
- uri |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment