by jameshiew · 1y ago · 0 comments
Refactoring duplicate code into a helper function should be achievable with current agents. To replace existing code with an external crate , you could try giving the agent access to a browser (e.g. playwright-mcp), and instructing it to browse the crate docs. For anything that involves using APIs that may be past the knowledge cutoff for the agent's model, it's definitely worthwhile to have some MCP tools on hand that'll let it browse for up-to-date info - the brave-search and context7 MCPs are good.
{
"servers": {
"context7": {
"command": "npx",
"args": [
"-y",
"@upstash/context7-mcp"
],
"type": "stdio"
},
"fetch": {
"command": "uvx",
"args": [
"mcp-server-fetch"
],
"type": "stdio"
},
"git": {
"command": "uvx",
"args": [
"mcp-server-git"
],
"type": "stdio"
},
"playwright": {
"command": "npx",
"args": [
"@playwright/mcp@latest"
],
"type": "stdio"
},
"brave-search": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-brave-search"
],
"env": {
"BRAVE_API_KEY": "${input:brave-api-key}"
},
"type": "stdio"
}
},
"inputs": [
{
"type": "promptString",
"id": "brave-api-key",
"description": "Brave Data for AI API Key",
"password": true
}
]
}
The Sonnet 4 agent usually defaults to using `fetch` for getting webpages, but I've seen it sometimes try playwright on it's own. It seems the brave-search MCP server is deprecated now, so actually it's probably not the best option as a search MCP (you also need to sign up for an API key), right now it works well though!