A Mastra template for smart AI agents that dynamically discover, install, and use MCP servers
This server provides 3 tools for MCP server discovery and management within a Mastra agent context. All tools have explicit Zod schemas and descriptions, but definitions suffer from significant gaps in parameter descriptions, missing output field documentation, and absent error recovery guidance. Tool naming is adequate (verb-driven) but descriptions lack the specificity needed for optimal LLM decision-making. Parameter validation is present but underdocumented. No tool annotations (readOnlyHint/destructiveHint) despite clear read/write semantics. Schemas are well-structured in JSON but descriptions fall short of the 10 - 1024 char baseline for comprehension, and critical parameter dependencies are underdocumented.
Add an MCP server by dynamically modifying the mcp.ts file configuration
Search for MCP servers on Smithery
List all MCP servers currently configured in the mcp.ts file
add-mcp-server is a destructive operation (file modification) with no destructiveHint annotation, no confirmation/dry-run pattern, and no undo tool. Agents can irreversibly corrupt mcp.ts without warning.
discover-servers silently returns empty array on API failure without error classification or recovery guidance. LLM cannot distinguish 'no servers match query' from 'API is down; retry later'.
All three tools lack input parameter descriptions in the code. Parameters like 'query', 'limit', 'name', 'serverId' have Zod constraints but no natural-language descriptions to guide LLM invocation.
list-servers output schema omits field descriptions. The 'type' field returns values like 'smithery', 'filesystem', 'unknown' but the Zod schema has no descriptions or enums, LLM must infer meanings from execute code.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-22 | D | 50 | 2025-06-18+ | v2 |
| 2026-03-09 | F | 44 | - | v1 |
No tool annotations (readOnlyHint/destructiveHint/idempotentHint) present despite clear semantics: discover-servers and list-servers are read-only; add-mcp-server is destructive.
Tool descriptions are under the optimal range (10 - 200 chars for LLM clarity). discover-servers (38 chars) is too brief; add-mcp-server (97 chars) and list-servers (70 chars) are adequate but lack context (WHEN, WHY, prerequisites).
add-mcp-server returns a long user-facing message (UI instructions) in the structured output. This wastes LLM tokens and violates the separation of machine and human interfaces. Should return only structured fields and let the client render UX.
list-servers uses regex fragile parsing (pattern: /\w+:\s*\{\s*command:/) to detect server configuration. Whitespace or format changes break detection. No validation that parsed values are correct. Should fail explicitly if mcp.ts structure is unexpected.