get_ai_guidance
Retrieve structured guidance for MCP server development on topics like security, performance, and best practices. Follow MCP SDK patterns, implement process cleanup, and use modern typing for server-specific recommendations.
Instructions
Get structured guidance for MCP server development.
IMPORTANT NOTES:
- AI sampling (ctx.sample) is NOT currently supported in Claude Desktop
- Use modern typing: dict, list, str | None instead of Dict, List, Optional
- Always implement proper process cleanup and signal handling
- Follow MCP SDK patterns for tools, resources, and prompts
This tool provides structured, deterministic guidance instead of AI-generated content.
For dynamic AI assistance, use Claude Desktop's built-in capabilities directly.
Args:
topic: Topic to get guidance on (best_practices, security, performance, typing, etc.)
server_type: Type of server for contextualized advice
Returns:
Structured guidance and recommendations with working code patterns
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| server_type | No | general | |
| topic | Yes |
Implementation Reference
- main.py:165-246 (handler)Handler and registration for the get_ai_guidance tool. The @mcp.tool() decorator registers the async function which provides structured AI guidance for MCP server development topics using hardcoded templates.@mcp.tool() async def get_ai_guidance( ctx: Context, topic: str, server_type: str = "general", ) -> str: """ Get structured guidance for MCP server development. IMPORTANT NOTES: - AI sampling (ctx.sample) is NOT currently supported in Claude Desktop - Use modern typing: dict, list, str | None instead of Dict, List, Optional - Always implement proper process cleanup and signal handling - Follow MCP SDK patterns for tools, resources, and prompts This tool provides structured, deterministic guidance instead of AI-generated content. For dynamic AI assistance, use Claude Desktop's built-in capabilities directly. Args: topic: Topic to get guidance on (best_practices, security, performance, typing, etc.) server_type: Type of server for contextualized advice Returns: Structured guidance and recommendations with working code patterns """ try: guidance_prompt = f""" Provide comprehensive guidance for MCP server development on the topic: {topic} Context: Creating a {server_type} MCP server Please include: 1. Key best practices 2. Common pitfalls to avoid 3. Security considerations 4. Performance optimization tips 5. Specific recommendations for this server type Format the response clearly with actionable advice. """ # Note: AI sampling is not currently supported in Claude Desktop # Providing structured guidance template instead guidance = f""" ## MCP Server Development Guidance - {topic.title()} ### Best Practices for {server_type} servers: 1. **Process Management**: Implement signal handlers and cleanup functions 2. **Error Handling**: Use try/catch blocks with meaningful error messages 3. **Security**: Validate all inputs and sanitize data 4. **Performance**: Use async/await patterns and connection pooling 5. **Logging**: Log to stderr for MCP compliance ### Common Pitfalls: - Missing process cleanup leading to resource leaks - Blocking operations without async/await - Inadequate input validation - Poor error messages that don't help debugging ### Security Considerations: - Always validate and sanitize user inputs - Implement rate limiting for resource-intensive operations - Use environment variables for sensitive configuration - Follow principle of least privilege ### Performance Tips: - Cache expensive operations when possible - Use connection pooling for databases - Implement proper timeouts - Monitor resource usage ### Specific Recommendations for {server_type}: - Follow existing patterns in the MCP-Creator templates - Test with small inputs before scaling - Implement graceful degradation for failures - Document your API clearly """ return f"🧠 AI Guidance - {topic.title()}:\n\n{guidance}" except Exception as e: logger.error(f"Failed to get AI guidance for topic '{topic}': {e}") return f"❌ Error getting guidance: {str(e)}"
- main.py:165-165 (registration)The @mcp.tool() decorator registers the get_ai_guidance function as an MCP tool.@mcp.tool()
- main.py:183-189 (schema)Input schema defined by function parameters and docstring: topic (str, required), server_type (str, optional default 'general'). Output is str.Args: topic: Topic to get guidance on (best_practices, security, performance, typing, etc.) server_type: Type of server for contextualized advice Returns: Structured guidance and recommendations with working code patterns """