@diffra-ai/cli 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/bundle/chunks/{anthropic-messages-UM2LSKVG.js → anthropic-messages-X6WVALGW.js} +1 -1
  3. package/dist/bundle/chunks/{azure-openai-responses-LLULQ6UR.js → azure-openai-responses-NWJUHXDZ.js} +1 -1
  4. package/dist/bundle/chunks/bedrock-converse-stream.js +1 -1
  5. package/dist/bundle/chunks/chunk-33NXM7QU.js +30 -0
  6. package/dist/bundle/chunks/{chunk-UBBD6YWP.js → chunk-7CGSQK56.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-6NW7EDTU.js → chunk-C5DQBSLC.js} +6 -6
  8. package/dist/bundle/chunks/{chunk-37INV3TW.js → chunk-IQ4GJTRS.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-MWJ5PWKE.js → chunk-JZRWXZHG.js} +1 -1
  10. package/dist/bundle/chunks/{chunk-Y5LGEDHU.js → chunk-L2DZJPGE.js} +1 -1
  11. package/dist/bundle/chunks/{chunk-J2CQ7AOB.js → chunk-QNL2W5AW.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-I6QEKFFB.js → chunk-RV73LYFM.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-BSCVN57O.js → chunk-WO7C3QOT.js} +1 -1
  14. package/dist/bundle/chunks/{chunk-QCEU5NDS.js → chunk-WYEDFTGD.js} +1 -1
  15. package/dist/bundle/chunks/{chunk-MAMCTGRH.js → chunk-XT6WUZXZ.js} +1 -1
  16. package/dist/bundle/chunks/{cli-VEFNOOXB.js → cli-LFWEPHUW.js} +1 -1
  17. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-VQHACWH5.js → cloudflare-workers-ai-system-one-TVT4UQJJ.js} +1 -1
  18. package/dist/bundle/chunks/github-copilot.js +1 -1
  19. package/dist/bundle/chunks/{google-generative-ai-YFRD2UAD.js → google-generative-ai-MBGYEF7P.js} +1 -1
  20. package/dist/bundle/chunks/{google-vertex-7EWCT4BL.js → google-vertex-BOTZRVRN.js} +1 -1
  21. package/dist/bundle/chunks/{llama-cpp-classify-D5PC6EEP.js → llama-cpp-classify-OLEUL2TP.js} +1 -1
  22. package/dist/bundle/chunks/{mistral-conversations-ILNLXCLF.js → mistral-conversations-5P5FZUVD.js} +1 -1
  23. package/dist/bundle/chunks/{openai-codex-responses-YESP5ZRN.js → openai-codex-responses-3AFER2OO.js} +1 -1
  24. package/dist/bundle/chunks/{openai-completions-BKYCRYVB.js → openai-completions-KCHGXEPR.js} +1 -1
  25. package/dist/bundle/chunks/{openai-decisions-OZVDLRU3.js → openai-decisions-V6S27AJQ.js} +1 -1
  26. package/dist/bundle/chunks/{openai-responses-GSXMBGMK.js → openai-responses-3SN2VI4R.js} +1 -1
  27. package/dist/bundle/chunks/{openrouter-images-TK5PJTOE.js → openrouter-images-QHMQBMZX.js} +1 -1
  28. package/dist/bundle/chunks/{pi-messages-AHAEGVU4.js → pi-messages-4P7GT7ZM.js} +1 -1
  29. package/dist/bundle/chunks/{typesafe-system-one-XHINCFVH.js → typesafe-system-one-QXVNQK47.js} +1 -1
  30. package/dist/bundle/chunks/{virtual-modules-7F3I52A6.js → virtual-modules-5D2HOQQM.js} +1 -1
  31. package/dist/bundle/cli-runtime.js +1 -1
  32. package/dist/bundle/cli.js +0 -0
  33. package/dist/bundle/index.js +1 -1
  34. package/dist/bundle/rpc-entry.js +1 -1
  35. package/dist/cli.js +0 -0
  36. package/dist/core/model-resolver.js +3 -3
  37. package/dist/core/model-resolver.js.map +1 -1
  38. package/dist/extensions/skills/bundled/find-skills/LICENSE +21 -0
  39. package/dist/extensions/skills/bundled/find-skills/SKILL.md +117 -0
  40. package/dist/extensions/skills/bundled/grill-me/LICENSE +21 -0
  41. package/dist/extensions/skills/bundled/grill-me/SKILL.md +44 -0
  42. package/dist/extensions/skills/bundled/handoff/LICENSE +21 -0
  43. package/dist/extensions/skills/bundled/handoff/SKILL.md +31 -0
  44. package/dist/extensions/skills/bundled/mcp-builder/LICENSE.txt +202 -0
  45. package/dist/extensions/skills/bundled/mcp-builder/SKILL.md +260 -0
  46. package/dist/extensions/skills/bundled/mcp-builder/reference/evaluation.md +432 -0
  47. package/dist/extensions/skills/bundled/mcp-builder/reference/mcp_best_practices.md +249 -0
  48. package/dist/extensions/skills/bundled/mcp-builder/reference/node_mcp_server.md +972 -0
  49. package/dist/extensions/skills/bundled/mcp-builder/reference/node_mcp_server_v2.md +747 -0
  50. package/dist/extensions/skills/bundled/mcp-builder/reference/python_mcp_server.md +719 -0
  51. package/dist/extensions/skills/bundled/ui-ux-pro-max/LICENSE +21 -0
  52. package/dist/extensions/skills/bundled/ui-ux-pro-max/SKILL.md +251 -0
  53. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/app-interface.csv +33 -0
  54. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/charts.csv +26 -0
  55. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/colors.csv +195 -0
  56. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/google-fonts.csv +1935 -0
  57. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/icons.csv +106 -0
  58. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/landing.csv +35 -0
  59. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/motion.csv +21 -0
  60. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/products.csv +195 -0
  61. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/react-performance.csv +45 -0
  62. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/angular.csv +51 -0
  63. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/astro.csv +54 -0
  64. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/avalonia.csv +57 -0
  65. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
  66. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/html-tailwind.csv +60 -0
  67. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/javafx.csv +76 -0
  68. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
  69. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/laravel.csv +51 -0
  70. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/nextjs.csv +62 -0
  71. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/nuxt-ui.csv +84 -0
  72. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/nuxtjs.csv +68 -0
  73. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/pyside6-qss.csv +103 -0
  74. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
  75. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/react.csv +67 -0
  76. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/shadcn.csv +69 -0
  77. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/svelte.csv +56 -0
  78. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
  79. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/threejs.csv +54 -0
  80. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/uno.csv +60 -0
  81. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/uwp.csv +56 -0
  82. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/vue.csv +50 -0
  83. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/winui.csv +60 -0
  84. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/stacks/wpf.csv +57 -0
  85. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/styles.csv +90 -0
  86. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/typography.csv +75 -0
  87. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/ui-reasoning.csv +195 -0
  88. package/dist/extensions/skills/bundled/ui-ux-pro-max/data/ux-guidelines.csv +142 -0
  89. package/dist/extensions/skills/bundled/ui-ux-pro-max/references/pro-rules.md +117 -0
  90. package/dist/extensions/skills/bundled/ui-ux-pro-max/references/quick-reference.md +275 -0
  91. package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/core.py +1111 -0
  92. package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/design_system.py +1922 -0
  93. package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/preview.py +557 -0
  94. package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/reasoning_contract.py +123 -0
  95. package/dist/extensions/skills/bundled/ui-ux-pro-max/scripts/search.py +257 -0
  96. package/dist/extensions/skills/index.d.ts +4 -4
  97. package/dist/extensions/skills/index.d.ts.map +1 -1
  98. package/dist/extensions/skills/index.js +9 -4
  99. package/dist/extensions/skills/index.js.map +1 -1
  100. package/dist/rpc-entry.js +0 -0
  101. package/docs/builtin-skills.md +46 -3
  102. package/docs/docs.json +1 -1
  103. package/docs/skills.md +1 -1
  104. package/docs/slash-commands.md +2 -0
  105. package/examples/extensions/doom-overlay/doom/build/doom.wasm +0 -0
  106. package/examples/extensions/doom-overlay/doom/build.sh +0 -0
  107. package/package.json +6 -6
  108. package/dist/bundle/chunks/chunk-UIVU7TEF.js +0 -30
@@ -0,0 +1,260 @@
1
+ ---
2
+ name: mcp-builder
3
+ description: Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).
4
+ license: Apache-2.0 (complete terms in LICENSE.txt). Adapted for Diffra from anthropics/skills.
5
+ ---
6
+
7
+ # MCP Server Development Guide
8
+
9
+ ## Overview
10
+
11
+ Create MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. The quality of an MCP server is measured by how well it enables LLMs to accomplish real-world tasks.
12
+
13
+ ---
14
+
15
+ # Process
16
+
17
+ ## 🚀 High-Level Workflow
18
+
19
+ Creating a high-quality MCP server involves four main phases:
20
+
21
+ ### Phase 1: Deep Research and Planning
22
+
23
+ #### 1.1 Understand Modern MCP Design
24
+
25
+ **API Coverage vs. Workflow Tools:**
26
+ Balance comprehensive API endpoint coverage with specialized workflow tools. Workflow tools can be more convenient for specific tasks, while comprehensive coverage gives agents flexibility to compose operations. Performance varies by client—some clients benefit from code execution that combines basic tools, while others work better with higher-level workflows. When uncertain, prioritize comprehensive API coverage.
27
+
28
+ **Tool Naming and Discoverability:**
29
+ Clear, descriptive tool names help agents find the right tools quickly. Use consistent prefixes (e.g., `github_create_issue`, `github_list_repos`) and action-oriented naming.
30
+
31
+ **Context Management:**
32
+ Agents benefit from concise tool descriptions and the ability to filter/paginate results. Design tools that return focused, relevant data. Some clients support code execution which can help agents filter and process data efficiently.
33
+
34
+ **Actionable Error Messages:**
35
+ Error messages should guide agents toward solutions with specific suggestions and next steps.
36
+
37
+ #### 1.2 Study MCP Protocol Documentation
38
+
39
+ **Navigate the MCP specification:**
40
+
41
+ Start with the sitemap to find relevant pages: `https://modelcontextprotocol.io/sitemap.xml`
42
+
43
+ Then fetch specific pages with `.md` suffix for markdown format (e.g., `https://modelcontextprotocol.io/specification/draft.md`).
44
+
45
+ Key pages to review:
46
+ - Specification overview and architecture
47
+ - Transport mechanisms (streamable HTTP, stdio)
48
+ - Tool, resource, and prompt definitions
49
+
50
+ #### 1.3 Study Framework Documentation
51
+
52
+ **Recommended stack:**
53
+ - **Language**: TypeScript (high-quality SDK support and good compatibility in many execution environments e.g. MCPB. Plus AI models are good at generating TypeScript code, benefiting from its broad usage, static typing and good linting tools)
54
+ - **Transport**: Streamable HTTP for remote servers, using stateless JSON (simpler to scale and maintain, as opposed to stateful sessions and streaming responses). stdio for local servers.
55
+
56
+ **Load framework documentation:**
57
+
58
+ - **MCP Best Practices**: [📋 View Best Practices](./reference/mcp_best_practices.md) - Core guidelines
59
+
60
+ **For TypeScript (recommended):**
61
+
62
+ The TypeScript SDK has two major versions. Pick one before writing code:
63
+ - **v2** (`@modelcontextprotocol/server`): the current stable release. Use it for new servers.
64
+ - **v1** (`@modelcontextprotocol/sdk`): receives bug and security fixes only. Use it only when the project's `package.json` already depends on `@modelcontextprotocol/sdk`, or migrate that project with `npx @modelcontextprotocol/codemod@latest v1-to-v2 .`
65
+
66
+ If the project already uses v1, tell the user once, in a sentence or two, that v2 (`@modelcontextprotocol/server`) is the current stable release, that v1 receives only bug and security fixes, and that `npx @modelcontextprotocol/codemod@latest v1-to-v2 .` migrates the project. Then continue with v1 unless the user asks to migrate.
67
+
68
+ Don't mix the two in one project: v1 code samples (imports from `@modelcontextprotocol/sdk/...`) don't apply to v2.
69
+
70
+ - **TypeScript SDK (v2)**: Use `web_fetch` to load `https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/main/README.md`; the full docs index is `https://ts.sdk.modelcontextprotocol.io/v2/llms.txt`
71
+ - [⚡ TypeScript Guide (v2)](./reference/node_mcp_server_v2.md) - TypeScript patterns and examples
72
+ - For v1 projects only: `https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/v1.x/README.md` and the [TypeScript Guide (v1)](./reference/node_mcp_server.md)
73
+
74
+ **For Python:**
75
+ - **Python SDK**: Use `web_fetch` to load `https://raw.githubusercontent.com/modelcontextprotocol/python-sdk/main/README.md`
76
+ - [🐍 Python Guide](./reference/python_mcp_server.md) - Python patterns and examples
77
+
78
+ #### 1.4 Plan Your Implementation
79
+
80
+ **Understand the API:**
81
+ Review the service's API documentation to identify key endpoints, authentication requirements, and data models. Use `web_search` and `web_fetch` as needed.
82
+
83
+ **Tool Selection:**
84
+ Prioritize comprehensive API coverage. List endpoints to implement, starting with the most common operations.
85
+
86
+ ---
87
+
88
+ ### Phase 2: Implementation
89
+
90
+ #### 2.1 Set Up Project Structure
91
+
92
+ See language-specific guides for project setup:
93
+ - [⚡ TypeScript Guide (v2)](./reference/node_mcp_server_v2.md) - Project structure, package.json, tsconfig.json ([v1](./reference/node_mcp_server.md) for existing v1 projects)
94
+ - [🐍 Python Guide](./reference/python_mcp_server.md) - Module organization, dependencies
95
+
96
+ #### 2.2 Implement Core Infrastructure
97
+
98
+ Create shared utilities:
99
+ - API client with authentication
100
+ - Error handling helpers
101
+ - Response formatting (JSON/Markdown)
102
+ - Pagination support
103
+
104
+ #### 2.3 Implement Tools
105
+
106
+ For each tool:
107
+
108
+ **Input Schema:**
109
+ - Use Zod (TypeScript) or Pydantic (Python)
110
+ - Include constraints and clear descriptions
111
+ - Add examples in field descriptions
112
+
113
+ **Output Schema:**
114
+ - Define `outputSchema` where possible for structured data
115
+ - Use `structuredContent` in tool responses (TypeScript SDK feature)
116
+ - Helps clients understand and process tool outputs
117
+
118
+ **Tool Description:**
119
+ - Concise summary of functionality
120
+ - Parameter descriptions
121
+ - Return type schema
122
+
123
+ **Implementation:**
124
+ - Async/await for I/O operations
125
+ - Proper error handling with actionable messages
126
+ - Support pagination where applicable
127
+ - Return both text content and structured data when using modern SDKs
128
+
129
+ **Annotations:**
130
+ - `readOnlyHint`: true/false
131
+ - `destructiveHint`: true/false
132
+ - `idempotentHint`: true/false
133
+ - `openWorldHint`: true/false
134
+
135
+ ---
136
+
137
+ ### Phase 3: Review and Test
138
+
139
+ #### 3.1 Code Quality
140
+
141
+ Review for:
142
+ - No duplicated code (DRY principle)
143
+ - Consistent error handling
144
+ - Full type coverage
145
+ - Clear tool descriptions
146
+
147
+ #### 3.2 Build and Test
148
+
149
+ **TypeScript:**
150
+ - Run `npm run build` to verify compilation
151
+ - v2 projects: run the self-check script from the [v2 guide](./reference/node_mcp_server_v2.md#verify-your-server) against the built server
152
+ - Test with MCP Inspector: `npx @modelcontextprotocol/inspector`
153
+
154
+ **Python:**
155
+ - Verify syntax: `python -m py_compile your_server.py`
156
+ - Test with MCP Inspector
157
+
158
+ **In Diffra:**
159
+ - Register the server and check that it connects and lists its tools: `diffra mcp add <name> -- <command> [args...]` (or `--url <url>` for Streamable HTTP), then `diffra mcp list`
160
+ - Ask the user before adding it to their configuration, and remove a test entry afterwards with `diffra mcp remove <name>`
161
+
162
+ See language-specific guides for detailed testing approaches and quality checklists.
163
+
164
+ ---
165
+
166
+ ### Phase 4: Create Evaluations
167
+
168
+ After implementing your MCP server, create comprehensive evaluations to test its effectiveness.
169
+
170
+ **Load [✅ Evaluation Guide](./reference/evaluation.md) for complete evaluation guidelines.**
171
+
172
+ #### 4.1 Understand Evaluation Purpose
173
+
174
+ Use evaluations to test whether LLMs can effectively use your MCP server to answer realistic, complex questions.
175
+
176
+ #### 4.2 Create 10 Evaluation Questions
177
+
178
+ To create effective evaluations, follow the process outlined in the evaluation guide:
179
+
180
+ 1. **Tool Inspection**: List available tools and understand their capabilities
181
+ 2. **Content Exploration**: Use READ-ONLY operations to explore available data
182
+ 3. **Question Generation**: Create 10 complex, realistic questions
183
+ 4. **Answer Verification**: Solve each question yourself to verify answers
184
+
185
+ #### 4.3 Evaluation Requirements
186
+
187
+ Ensure each question is:
188
+ - **Independent**: Not dependent on other questions
189
+ - **Read-only**: Only non-destructive operations required
190
+ - **Complex**: Requiring multiple tool calls and deep exploration
191
+ - **Realistic**: Based on real use cases humans would care about
192
+ - **Verifiable**: Single, clear answer that can be verified by string comparison
193
+ - **Stable**: Answer won't change over time
194
+
195
+ #### 4.4 Output Format
196
+
197
+ Create an XML file with this structure:
198
+
199
+ ```xml
200
+ <evaluation>
201
+ <qa_pair>
202
+ <question>Find discussions about AI model launches with animal codenames. One model needed a specific safety designation that uses the format ASL-X. What number X was being determined for the model named after a spotted wild cat?</question>
203
+ <answer>3</answer>
204
+ </qa_pair>
205
+ <!-- More qa_pairs... -->
206
+ </evaluation>
207
+ ```
208
+
209
+ #### 4.5 Run the Evaluation
210
+
211
+ Run each question in a fresh, non-interactive Diffra run that may use only the server's tools, then grade the answers. The [Evaluation Guide](./reference/evaluation.md#running-evaluations) has the commands.
212
+
213
+ ---
214
+
215
+ # Reference Files
216
+
217
+ ## 📚 Documentation Library
218
+
219
+ Load these resources as needed during development:
220
+
221
+ ### Core MCP Documentation (Load First)
222
+ - **MCP Protocol**: Start with sitemap at `https://modelcontextprotocol.io/sitemap.xml`, then fetch specific pages with `.md` suffix
223
+ - [📋 MCP Best Practices](./reference/mcp_best_practices.md) - Universal MCP guidelines including:
224
+ - Server and tool naming conventions
225
+ - Response format guidelines (JSON vs Markdown)
226
+ - Pagination best practices
227
+ - Transport selection (streamable HTTP vs stdio)
228
+ - Security and error handling standards
229
+
230
+ ### SDK Documentation (Load During Phase 1/2)
231
+ - **Python SDK**: Fetch from `https://raw.githubusercontent.com/modelcontextprotocol/python-sdk/main/README.md`
232
+ - **TypeScript SDK (v2)**: Fetch from `https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/main/README.md`; full docs index at `https://ts.sdk.modelcontextprotocol.io/v2/llms.txt`
233
+ - **TypeScript SDK (v1, existing v1 projects only)**: Fetch from `https://raw.githubusercontent.com/modelcontextprotocol/typescript-sdk/v1.x/README.md`
234
+
235
+ ### Language-Specific Implementation Guides (Load During Phase 2)
236
+ - [🐍 Python Implementation Guide](./reference/python_mcp_server.md) - Complete Python/FastMCP guide with:
237
+ - Server initialization patterns
238
+ - Pydantic model examples
239
+ - Tool registration with `@mcp.tool`
240
+ - Complete working examples
241
+ - Quality checklist
242
+
243
+ - [⚡ TypeScript Implementation Guide (SDK v2)](./reference/node_mcp_server_v2.md) - Complete TypeScript guide for `@modelcontextprotocol/server` with:
244
+ - Project setup and the server factory
245
+ - Tool design: Zod 4 schemas, output formats, pagination, errors
246
+ - A complete example serving stdio and Streamable HTTP, plus bearer auth
247
+ - Resources, prompts, and notifications
248
+ - A self-check script to verify the built server
249
+ - Links to SDK examples for advanced features
250
+ - A v1 → v2 translation table, migration steps, and a quality checklist
251
+
252
+ - [⚡ TypeScript Implementation Guide (SDK v1)](./reference/node_mcp_server.md) - The equivalent guide for existing `@modelcontextprotocol/sdk` projects
253
+
254
+ ### Evaluation Guide (Load During Phase 4)
255
+ - [✅ Evaluation Guide](./reference/evaluation.md) - Complete evaluation creation guide with:
256
+ - Question creation guidelines
257
+ - Answer verification strategies
258
+ - XML format specifications
259
+ - Example questions and answers
260
+ - Running an evaluation with Diffra (`diffra --print` with only the server's tools)
@@ -0,0 +1,432 @@
1
+ # MCP Server Evaluation Guide
2
+
3
+ ## Overview
4
+
5
+ This document provides guidance on creating comprehensive evaluations for MCP servers. Evaluations test whether LLMs can effectively use your MCP server to answer realistic, complex questions using only the tools provided.
6
+
7
+ ---
8
+
9
+ ## Quick Reference
10
+
11
+ ### Evaluation Requirements
12
+ - Create 10 human-readable questions
13
+ - Questions must be READ-ONLY, INDEPENDENT, NON-DESTRUCTIVE
14
+ - Each question requires multiple tool calls (potentially dozens)
15
+ - Answers must be single, verifiable values
16
+ - Answers must be STABLE (won't change over time)
17
+
18
+ ### Output Format
19
+ ```xml
20
+ <evaluation>
21
+ <qa_pair>
22
+ <question>Your question here</question>
23
+ <answer>Single verifiable answer</answer>
24
+ </qa_pair>
25
+ </evaluation>
26
+ ```
27
+
28
+ ---
29
+
30
+ ## Purpose of Evaluations
31
+
32
+ The measure of quality of an MCP server is NOT how well or comprehensively the server implements tools, but how well these implementations (input/output schemas, docstrings/descriptions, functionality) enable LLMs with no other context and access ONLY to the MCP servers to answer realistic and difficult questions.
33
+
34
+ ## Evaluation Overview
35
+
36
+ Create 10 human-readable questions requiring ONLY READ-ONLY, INDEPENDENT, NON-DESTRUCTIVE, and IDEMPOTENT operations to answer. Each question should be:
37
+ - Realistic
38
+ - Clear and concise
39
+ - Unambiguous
40
+ - Complex, requiring potentially dozens of tool calls or steps
41
+ - Answerable with a single, verifiable value that you identify in advance
42
+
43
+ ## Question Guidelines
44
+
45
+ ### Core Requirements
46
+
47
+ 1. **Questions MUST be independent**
48
+ - Each question should NOT depend on the answer to any other question
49
+ - Should not assume prior write operations from processing another question
50
+
51
+ 2. **Questions MUST require ONLY NON-DESTRUCTIVE AND IDEMPOTENT tool use**
52
+ - Should not instruct or require modifying state to arrive at the correct answer
53
+
54
+ 3. **Questions must be REALISTIC, CLEAR, CONCISE, and COMPLEX**
55
+ - Must require another LLM to use multiple (potentially dozens of) tools or steps to answer
56
+
57
+ ### Complexity and Depth
58
+
59
+ 4. **Questions must require deep exploration**
60
+ - Consider multi-hop questions requiring multiple sub-questions and sequential tool calls
61
+ - Each step should benefit from information found in previous questions
62
+
63
+ 5. **Questions may require extensive paging**
64
+ - May need paging through multiple pages of results
65
+ - May require querying old data (1-2 years out-of-date) to find niche information
66
+ - The questions must be DIFFICULT
67
+
68
+ 6. **Questions must require deep understanding**
69
+ - Rather than surface-level knowledge
70
+ - May pose complex ideas as True/False questions requiring evidence
71
+ - May use multiple-choice format where LLM must search different hypotheses
72
+
73
+ 7. **Questions must not be solvable with straightforward keyword search**
74
+ - Do not include specific keywords from the target content
75
+ - Use synonyms, related concepts, or paraphrases
76
+ - Require multiple searches, analyzing multiple related items, extracting context, then deriving the answer
77
+
78
+ ### Tool Testing
79
+
80
+ 8. **Questions should stress-test tool return values**
81
+ - May elicit tools returning large JSON objects or lists, overwhelming the LLM
82
+ - Should require understanding multiple modalities of data:
83
+ - IDs and names
84
+ - Timestamps and datetimes (months, days, years, seconds)
85
+ - File IDs, names, extensions, and mimetypes
86
+ - URLs, GIDs, etc.
87
+ - Should probe the tool's ability to return all useful forms of data
88
+
89
+ 9. **Questions should MOSTLY reflect real human use cases**
90
+ - The kinds of information retrieval tasks that HUMANS assisted by an LLM would care about
91
+
92
+ 10. **Questions may require dozens of tool calls**
93
+ - This challenges LLMs with limited context
94
+ - Encourages MCP server tools to reduce information returned
95
+
96
+ 11. **Include ambiguous questions**
97
+ - May be ambiguous OR require difficult decisions on which tools to call
98
+ - Force the LLM to potentially make mistakes or misinterpret
99
+ - Ensure that despite AMBIGUITY, there is STILL A SINGLE VERIFIABLE ANSWER
100
+
101
+ ### Stability
102
+
103
+ 12. **Questions must be designed so the answer DOES NOT CHANGE**
104
+ - Do not ask questions that rely on "current state" which is dynamic
105
+ - For example, do not count:
106
+ - Number of reactions to a post
107
+ - Number of replies to a thread
108
+ - Number of members in a channel
109
+
110
+ 13. **DO NOT let the MCP server RESTRICT the kinds of questions you create**
111
+ - Create challenging and complex questions
112
+ - Some may not be solvable with the available MCP server tools
113
+ - Questions may require specific output formats (datetime vs. epoch time, JSON vs. MARKDOWN)
114
+ - Questions may require dozens of tool calls to complete
115
+
116
+ ## Answer Guidelines
117
+
118
+ ### Verification
119
+
120
+ 1. **Answers must be VERIFIABLE via direct string comparison**
121
+ - If the answer can be re-written in many formats, clearly specify the output format in the QUESTION
122
+ - Examples: "Use YYYY/MM/DD.", "Respond True or False.", "Answer A, B, C, or D and nothing else."
123
+ - Answer should be a single VERIFIABLE value such as:
124
+ - User ID, user name, display name, first name, last name
125
+ - Channel ID, channel name
126
+ - Message ID, string
127
+ - URL, title
128
+ - Numerical quantity
129
+ - Timestamp, datetime
130
+ - Boolean (for True/False questions)
131
+ - Email address, phone number
132
+ - File ID, file name, file extension
133
+ - Multiple choice answer
134
+ - Answers must not require special formatting or complex, structured output
135
+ - Answer will be verified using DIRECT STRING COMPARISON
136
+
137
+ ### Readability
138
+
139
+ 2. **Answers should generally prefer HUMAN-READABLE formats**
140
+ - Examples: names, first name, last name, datetime, file name, message string, URL, yes/no, true/false, a/b/c/d
141
+ - Rather than opaque IDs (though IDs are acceptable)
142
+ - The VAST MAJORITY of answers should be human-readable
143
+
144
+ ### Stability
145
+
146
+ 3. **Answers must be STABLE/STATIONARY**
147
+ - Look at old content (e.g., conversations that have ended, projects that have launched, questions answered)
148
+ - Create QUESTIONS based on "closed" concepts that will always return the same answer
149
+ - Questions may ask to consider a fixed time window to insulate from non-stationary answers
150
+ - Rely on context UNLIKELY to change
151
+ - Example: if finding a paper name, be SPECIFIC enough so answer is not confused with papers published later
152
+
153
+ 4. **Answers must be CLEAR and UNAMBIGUOUS**
154
+ - Questions must be designed so there is a single, clear answer
155
+ - Answer can be derived from using the MCP server tools
156
+
157
+ ### Diversity
158
+
159
+ 5. **Answers must be DIVERSE**
160
+ - Answer should be a single VERIFIABLE value in diverse modalities and formats
161
+ - User concept: user ID, user name, display name, first name, last name, email address, phone number
162
+ - Channel concept: channel ID, channel name, channel topic
163
+ - Message concept: message ID, message string, timestamp, month, day, year
164
+
165
+ 6. **Answers must NOT be complex structures**
166
+ - Not a list of values
167
+ - Not a complex object
168
+ - Not a list of IDs or strings
169
+ - Not natural language text
170
+ - UNLESS the answer can be straightforwardly verified using DIRECT STRING COMPARISON
171
+ - And can be realistically reproduced
172
+ - It should be unlikely that an LLM would return the same list in any other order or format
173
+
174
+ ## Evaluation Process
175
+
176
+ ### Step 1: Documentation Inspection
177
+
178
+ Read the documentation of the target API to understand:
179
+ - Available endpoints and functionality
180
+ - If ambiguity exists, fetch additional information from the web
181
+ - Parallelize this step AS MUCH AS POSSIBLE
182
+ - Ensure each subagent is ONLY examining documentation from the file system or on the web
183
+
184
+ ### Step 2: Tool Inspection
185
+
186
+ List the tools available in the MCP server:
187
+ - Inspect the MCP server directly
188
+ - Understand input/output schemas, docstrings, and descriptions
189
+ - WITHOUT calling the tools themselves at this stage
190
+
191
+ ### Step 3: Developing Understanding
192
+
193
+ Repeat steps 1 & 2 until you have a good understanding:
194
+ - Iterate multiple times
195
+ - Think about the kinds of tasks you want to create
196
+ - Refine your understanding
197
+ - At NO stage should you READ the code of the MCP server implementation itself
198
+ - Use your intuition and understanding to create reasonable, realistic, but VERY challenging tasks
199
+
200
+ ### Step 4: Read-Only Content Inspection
201
+
202
+ After understanding the API and tools, USE the MCP server tools:
203
+ - Inspect content using READ-ONLY and NON-DESTRUCTIVE operations ONLY
204
+ - Goal: identify specific content (e.g., users, channels, messages, projects, tasks) for creating realistic questions
205
+ - Should NOT call any tools that modify state
206
+ - Will NOT read the code of the MCP server implementation itself
207
+ - Parallelize this step with individual sub-agents pursuing independent explorations
208
+ - Ensure each subagent is only performing READ-ONLY, NON-DESTRUCTIVE, and IDEMPOTENT operations
209
+ - BE CAREFUL: SOME TOOLS may return LOTS OF DATA which would cause you to run out of CONTEXT
210
+ - Make INCREMENTAL, SMALL, AND TARGETED tool calls for exploration
211
+ - In all tool call requests, use the `limit` parameter to limit results (<10)
212
+ - Use pagination
213
+
214
+ ### Step 5: Task Generation
215
+
216
+ After inspecting the content, create 10 human-readable questions:
217
+ - An LLM should be able to answer these with the MCP server
218
+ - Follow all question and answer guidelines above
219
+
220
+ ## Output Format
221
+
222
+ Each QA pair consists of a question and an answer. The output should be an XML file with this structure:
223
+
224
+ ```xml
225
+ <evaluation>
226
+ <qa_pair>
227
+ <question>Find the project created in Q2 2024 with the highest number of completed tasks. What is the project name?</question>
228
+ <answer>Website Redesign</answer>
229
+ </qa_pair>
230
+ <qa_pair>
231
+ <question>Search for issues labeled as "bug" that were closed in March 2024. Which user closed the most issues? Provide their username.</question>
232
+ <answer>sarah_dev</answer>
233
+ </qa_pair>
234
+ <qa_pair>
235
+ <question>Look for pull requests that modified files in the /api directory and were merged between January 1 and January 31, 2024. How many different contributors worked on these PRs?</question>
236
+ <answer>7</answer>
237
+ </qa_pair>
238
+ <qa_pair>
239
+ <question>Find the repository with the most stars that was created before 2023. What is the repository name?</question>
240
+ <answer>data-pipeline</answer>
241
+ </qa_pair>
242
+ </evaluation>
243
+ ```
244
+
245
+ ## Evaluation Examples
246
+
247
+ ### Good Questions
248
+
249
+ **Example 1: Multi-hop question requiring deep exploration (GitHub MCP)**
250
+ ```xml
251
+ <qa_pair>
252
+ <question>Find the repository that was archived in Q3 2023 and had previously been the most forked project in the organization. What was the primary programming language used in that repository?</question>
253
+ <answer>Python</answer>
254
+ </qa_pair>
255
+ ```
256
+
257
+ This question is good because:
258
+ - Requires multiple searches to find archived repositories
259
+ - Needs to identify which had the most forks before archival
260
+ - Requires examining repository details for the language
261
+ - Answer is a simple, verifiable value
262
+ - Based on historical (closed) data that won't change
263
+
264
+ **Example 2: Requires understanding context without keyword matching (Project Management MCP)**
265
+ ```xml
266
+ <qa_pair>
267
+ <question>Locate the initiative focused on improving customer onboarding that was completed in late 2023. The project lead created a retrospective document after completion. What was the lead's role title at that time?</question>
268
+ <answer>Product Manager</answer>
269
+ </qa_pair>
270
+ ```
271
+
272
+ This question is good because:
273
+ - Doesn't use specific project name ("initiative focused on improving customer onboarding")
274
+ - Requires finding completed projects from specific timeframe
275
+ - Needs to identify the project lead and their role
276
+ - Requires understanding context from retrospective documents
277
+ - Answer is human-readable and stable
278
+ - Based on completed work (won't change)
279
+
280
+ **Example 3: Complex aggregation requiring multiple steps (Issue Tracker MCP)**
281
+ ```xml
282
+ <qa_pair>
283
+ <question>Among all bugs reported in January 2024 that were marked as critical priority, which assignee resolved the highest percentage of their assigned bugs within 48 hours? Provide the assignee's username.</question>
284
+ <answer>alex_eng</answer>
285
+ </qa_pair>
286
+ ```
287
+
288
+ This question is good because:
289
+ - Requires filtering bugs by date, priority, and status
290
+ - Needs to group by assignee and calculate resolution rates
291
+ - Requires understanding timestamps to determine 48-hour windows
292
+ - Tests pagination (potentially many bugs to process)
293
+ - Answer is a single username
294
+ - Based on historical data from specific time period
295
+
296
+ **Example 4: Requires synthesis across multiple data types (CRM MCP)**
297
+ ```xml
298
+ <qa_pair>
299
+ <question>Find the account that upgraded from the Starter to Enterprise plan in Q4 2023 and had the highest annual contract value. What industry does this account operate in?</question>
300
+ <answer>Healthcare</answer>
301
+ </qa_pair>
302
+ ```
303
+
304
+ This question is good because:
305
+ - Requires understanding subscription tier changes
306
+ - Needs to identify upgrade events in specific timeframe
307
+ - Requires comparing contract values
308
+ - Must access account industry information
309
+ - Answer is simple and verifiable
310
+ - Based on completed historical transactions
311
+
312
+ ### Poor Questions
313
+
314
+ **Example 1: Answer changes over time**
315
+ ```xml
316
+ <qa_pair>
317
+ <question>How many open issues are currently assigned to the engineering team?</question>
318
+ <answer>47</answer>
319
+ </qa_pair>
320
+ ```
321
+
322
+ This question is poor because:
323
+ - The answer will change as issues are created, closed, or reassigned
324
+ - Not based on stable/stationary data
325
+ - Relies on "current state" which is dynamic
326
+
327
+ **Example 2: Too easy with keyword search**
328
+ ```xml
329
+ <qa_pair>
330
+ <question>Find the pull request with title "Add authentication feature" and tell me who created it.</question>
331
+ <answer>developer123</answer>
332
+ </qa_pair>
333
+ ```
334
+
335
+ This question is poor because:
336
+ - Can be solved with a straightforward keyword search for exact title
337
+ - Doesn't require deep exploration or understanding
338
+ - No synthesis or analysis needed
339
+
340
+ **Example 3: Ambiguous answer format**
341
+ ```xml
342
+ <qa_pair>
343
+ <question>List all the repositories that have Python as their primary language.</question>
344
+ <answer>repo1, repo2, repo3, data-pipeline, ml-tools</answer>
345
+ </qa_pair>
346
+ ```
347
+
348
+ This question is poor because:
349
+ - Answer is a list that could be returned in any order
350
+ - Difficult to verify with direct string comparison
351
+ - LLM might format differently (JSON array, comma-separated, newline-separated)
352
+ - Better to ask for a specific aggregate (count) or superlative (most stars)
353
+
354
+ ## Verification Process
355
+
356
+ After creating evaluations:
357
+
358
+ 1. **Examine the XML file** to understand the schema
359
+ 2. **Load each task instruction** and in parallel using the MCP server and tools, identify the correct answer by attempting to solve the task YOURSELF
360
+ 3. **Flag any operations** that require WRITE or DESTRUCTIVE operations
361
+ 4. **Accumulate all CORRECT answers** and replace any incorrect answers in the document
362
+ 5. **Remove any `<qa_pair>`** that require WRITE or DESTRUCTIVE operations
363
+
364
+ Remember to parallelize solving tasks to avoid running out of context, then accumulate all answers and make changes to the file at the end.
365
+
366
+ ## Tips for Creating Quality Evaluations
367
+
368
+ 1. **Think Hard and Plan Ahead** before generating tasks
369
+ 2. **Parallelize Where Opportunity Arises** to speed up the process and manage context
370
+ 3. **Focus on Realistic Use Cases** that humans would actually want to accomplish
371
+ 4. **Create Challenging Questions** that test the limits of the MCP server's capabilities
372
+ 5. **Ensure Stability** by using historical data and closed concepts
373
+ 6. **Verify Answers** by solving the questions yourself using the MCP server tools
374
+ 7. **Iterate and Refine** based on what you learn during the process
375
+
376
+ ---
377
+
378
+ # Running Evaluations
379
+
380
+ Run the evaluation with Diffra itself: register the server, then answer each question in a fresh, non-interactive Diffra run that may use only the server's tools, and compare the final answer with the expected one. No separate harness, API key, or Python package is needed; the runs use the model and credentials Diffra already has.
381
+
382
+ ## 1. Register the server for the evaluation
383
+
384
+ Give the server its own name and `direct` exposure, so the model sees its tools as ordinary tools:
385
+
386
+ ```bash
387
+ # stdio: Diffra starts the server itself
388
+ diffra mcp add eval_myserver --exposure direct -- node dist/index.js
389
+ diffra mcp add eval_myserver --exposure direct --env API_KEY='${MY_API_KEY}' -- python my_server.py
390
+
391
+ # Streamable HTTP: start the server first
392
+ diffra mcp add eval_myserver --exposure direct --url http://localhost:3000/mcp --bearer-token-env-var MY_TOKEN
393
+
394
+ diffra mcp list # check that it connects and lists its tools
395
+ ```
396
+
397
+ Add `-l` to write the project's `.diffra/mcp.json` instead of the user's `~/.diffra/agent/mcp.json`; project servers load only in a trusted project. Reference secrets as `${NAME}` environment variables, never as literal values.
398
+
399
+ ## 2. Answer each question in a fresh run
400
+
401
+ ```bash
402
+ diffra --print --no-session --tools 'mcp__eval_myserver__*' \
403
+ "Answer the question using only the available tools. End your reply with one line: ANSWER: <answer>. Question: <question>"
404
+ ```
405
+
406
+ - `--print` runs once and writes the final reply to stdout; `--no-session` saves nothing.
407
+ - `--tools 'mcp__eval_myserver__*'` declares only the server's tools: no file, shell, or web tools, so the answer has to come from the server.
408
+ - Add `--model <pattern>` to evaluate with another model, for example a smaller one, which shows whether the tool descriptions are clear enough.
409
+
410
+ Run the questions one at a time, or in parallel with subagents (the `agent` tool), one question each. A subagent that runs the command needs the `bash` tool.
411
+
412
+ ## 3. Grade and report
413
+
414
+ Take the text after `ANSWER:` from each reply and compare it with the expected `<answer>` after trimming whitespace and ignoring case. Write a report with:
415
+
416
+ - **Summary**: accuracy (correct / total).
417
+ - **Per question**: the question, the expected and actual answers, correct or not.
418
+ - **Tool feedback**: for each failure, what went wrong (a tool that was missing, a description that misled the model, a response too large or too terse, an unhelpful error) and the change to the server that would fix it.
419
+
420
+ Then improve the server and run the evaluation again.
421
+
422
+ ## 4. Clean up
423
+
424
+ ```bash
425
+ diffra mcp remove eval_myserver
426
+ ```
427
+
428
+ ## Troubleshooting
429
+
430
+ - **No tools**: `diffra mcp list` shows the server's state and error. Check the command and arguments, that an HTTP server is running, and that the environment variables it needs are set.
431
+ - **Low accuracy**: read the failed replies. Check whether tool descriptions are clear, input parameters documented, responses neither too large nor too small, and errors actionable.
432
+ - **Slow or truncated answers**: check whether tools return too much data and whether pagination works; consider simpler questions.