Adding tools to the GT MCP server
MCP server are useful with tools. In GT, the tools use the same model as in Adding tools to chats and can thus be shared across local agents and MCP servers.
Let's see it in practice. We create a server:
server := GtLMcpServer new port: 3001; start
And then we add a tool to it:
server addTool: (GtLMagritteToolForMethodImplementors new)
We can test it by connecting to it using an MCP client, like the one already built into GT (see Working with MCP servers through the GT MCP client).
client := GtLMcpClient new transport: (GtLMcpHttpTransport new url: 'http://localhost:3001/')
We can confirm the presence of the tools, either through navigating to the view on the client, or programmatically.
client listTools
Once we’ve confirmed that the client can see the tool, we can call it:
result := client
callTool: 'getImplementors'
withArguments: {'methodName' -> 'callTool:withArguments:'} asDictionary
STONJSON fromString: (result first at: 'text')
Stop the server once you're done playing with it.
server stop