Documentation Index
Fetch the complete documentation index at: https://mintlify.com/QwenLM/qwen-code/llms.txt
Use this file to discover all available pages before exploring further.
Creating MCP Server Extensions
Model Context Protocol (MCP) servers allow you to add custom tools that the AI can use. Through extensions, you can package and distribute MCP servers with all necessary configuration, making it easy for others to install and use your tools.What are MCP Servers?
MCP servers are:- Standalone processes that communicate via stdio (or other transports)
- Provide tools (functions) the AI can call
- Can expose prompts and resources
- Run continuously during your session
- Defined using the
@modelcontextprotocol/sdk
When to Use MCP Servers
Use MCP servers when you need to:- Integrate External APIs: GitHub, Slack, databases, etc.
- Add Specialized Tools: Image processing, data analysis, etc.
- Access Resources: Files, databases, web services
- Provide Prompts: Pre-configured AI prompts
- Execute Operations: Deploy, test, monitor, etc.
Extension Structure
Quick Start: Using Template
Create from the built-in MCP server template:Manual Setup
Step 1: Create Package Files
package.json:Step 2: Create MCP Server
server.ts:Step 3: Configure Extension
qwen-extension.json:Step 4: Build and Test
Registering Tools
Simple Tool
Tool with Multiple Parameters
Tool with API Call
Tool with Error Handling
Registering Prompts
Prompts are pre-configured AI prompts that users can invoke:Using Environment Variables
For API keys and sensitive data:Define Settings
qwen-extension.json:Access in Server
Example: GitHub MCP Server
A complete example integrating with GitHub API:Best Practices
1. Clear Tool Descriptions
2. Validate Input
3. Handle Errors Gracefully
4. Format Output Clearly
5. Document Parameter Purpose
MCP Server Configuration
Advanced configuration options:Debugging
Add logging to your MCP server:Next Steps
- Creating Extensions - Complete extension guide
- Context Providers - Document your tools
- Best Practices - Development guidelines
- Releasing - Publish your extension
