chore: refactor MCP server to use AI SDK tools#68
Conversation
Replace custom tool implementations with AI SDK tools to reduce code duplication. Addresses issue amp-labs#40 by consolidating all MCP tool logic into the AI SDK. - Use createWriteActionTool, createCheckConnectionTool, createCreateInstallationTool, createCheckInstallationTool, createStartOAuthTool, and createSendRequestTool from @amp-labs/ai/mcp - Remove duplicate tool implementations (connection.ts, oauth.ts, request.ts, write.ts) - Add createSendReadRequestTool for backward compatibility - Maintain same API surface for existing MCP clients
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the MCP server to consolidate all custom tool implementations into the shared AI SDK, removes duplicate code, and adds a backward-compatible send-read-request tool.
- Removed standalone tool implementations in
write.ts,request.ts,oauth.ts, andconnection.ts - Imported and wired up SDK-provided tools (
createWriteActionTool,createCheckConnectionTool,createCreateInstallationTool,createCheckInstallationTool,createStartOAuthTool,createSendRequestTool) - Added an inline
createSendReadRequestToolinindex.tsfor backward compatibility
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| mcp-server/src/write.ts | Removed custom create/update write tools, now using SDK’s createWriteActionTool. |
| mcp-server/src/request.ts | Deleted custom send-request and send-read-request tools in favor of SDK’s createSendRequestTool. |
| mcp-server/src/oauth.ts | Deleted custom OAuth flow tool, now using SDK’s createStartOAuthTool. |
| mcp-server/src/index.ts | Updated imports to pull tools from the AI SDK, inlined backward compatibility send-read-request tool, and updated tool registration order. |
| mcp-server/src/connection.ts | Removed custom connection and installation tools, replaced by SDK’s createCheckConnectionTool, createCreateInstallationTool, and createCheckInstallationTool. |
Comments suppressed due to low confidence (1)
mcp-server/src/index.ts:34
- Since
createSendReadRequestToolwas added for backward compatibility, ensure you have unit or integration tests covering both successful GET requests and error scenarios for this tool.
async function createSendReadRequestTool(
|
|
||
| export type ClientSettings = typeof clientSettings; | ||
|
|
||
| async function createSendReadRequestTool( |
There was a problem hiding this comment.
The createSendReadRequestTool implementation in index.ts duplicates logic that could be centralized; consider extracting it into its own module or upgrading the AI SDK with a first-class createSendReadRequestTool export to avoid local duplication.
| }, | ||
| ], | ||
| }; | ||
| } catch (error) { |
There was a problem hiding this comment.
The catch block for send-read-request currently suppresses errors without logging; add a console.error (or use the project's logging utility) here to aid in debugging failed requests.
| } catch (error) { | |
| } catch (error) { | |
| console.error('Error occurred in send-read-request tool:', error); |
Replace custom tool implementations with AI SDK tools to reduce code duplication. Addresses issue #40 by consolidating all MCP tool logic into the AI SDK.