Adding prompts to the GT MCP server
The MCP server can generate prompts based on a given template.
Start the server:
server := GtLMcpServer new port: 3003; start
Add a prompt to it:
server
addPrompt: (GtLMcpPrompt new
name: 'Code Review';
description: 'Asks the LLM to analyze code quality and suggest improvements';
arguments: {'code'};
promptBlock: [ :arguments |
{GtLAnthropicUserMessage new
markdown: 'Review the following code as if you were a senior developer:
```
' , (arguments at: 'code')
, '
```'} ])
Once we have the prompt, we can access it from the client. For example, we can set up a GT client:
client := GtLMcpClient new transport: (GtLMcpHttpTransport new url: 'http://localhost:3003/')
And create messages from it directly.
(client
messagesFromPrompt: 'Code Review'
withArguments: {'code' -> '(defn a-clojure-fn [x] (* x 2))'} asDictionary)
first
Stop the server once you're done with it:
server stop