-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Enhancement Request
The current MCP server template only includes a basic "hello" tool example. Adding more comprehensive examples would help users understand MCP patterns better.
Suggested Examples to Add
1. File Handling Tool
@mcp.tool()
async def read_file(path: str) -> str:
"""Read contents of a file with proper error handling."""
# Example implementation2. API Integration Tool
@mcp.tool()
async def fetch_data(url: str, headers: Optional[Dict] = None) -> Dict:
"""Fetch data from an API endpoint."""
# Example with aiohttp or httpx3. Authentication Management
@mcp.tool()
async def verify_token(token: str) -> bool:
"""Verify authentication token."""
# Example token validation4. Database Operations
@mcp.tool()
async def query_database(query: str, params: Optional[List] = None) -> List[Dict]:
"""Execute database query with parameterized inputs."""
# Example with SQLAlchemy or asyncpg5. Data Processing
@mcp.tool()
async def process_json(data: Dict, schema: Optional[Dict] = None) -> Dict:
"""Process and validate JSON data."""
# Example with pydantic or marshmallowBenefits
- Faster onboarding for new users
- Best practices demonstration
- Common patterns readily available
- Reduced development time
Implementation Suggestions
- Create a
tools/examples/directory in the template - Include well-commented example files
- Add a README explaining each example
- Include tests for each example tool
Documentation
Each example should include:
- Clear docstrings
- Input/output types
- Error handling
- Usage examples
- Common pitfalls to avoid
Metadata
Metadata
Assignees
Labels
No labels