Skip to content

Model Context Protocol Tools

Logo of the Model Context Protocol project.

Model Context Protocol (MCP) is an emerging standard for portable tool definitions.

The MCP defines a protocol that allows to share tools and consume them regardless of the underlying framework/runtime.

GenAIScript implements a client for MCP tools.

Configuring servers

You can use defTool to declare a set of server configurations, using the same syntax as in the Claude configuration file.

defTool({
memory: {
command: "npx",
args: ["-y", "@modelcontextprotocol/server-memory"],
},
filesystem: {
command: "npx",
args: [
"-y",
"@modelcontextprotocol/server-filesystem",
path.resolve("."),
],
},
})

GenAIScript will launch the server and register all the tools listed by the server. The tool identifier will be server_toolname to avoid clashes.

Lifecycle of servers

Servers are started when rendering the prompt and stopped once the chat session is completed.

This means that if you define servers in an inline prompt, the server will be started/stopped for each inline prompt.

Finding servers

The list of available servers can be found in the Model Context Protocol Servers project.