mcp-vultr/test_async_fastmcp.py
Ryan Malloy 75ffe33008 Migrate to FastMCP and add comprehensive improvements
Major changes:
- Migrate from low-level MCP to FastMCP framework for better compatibility
- Add custom exception hierarchy (VultrAPIError, VultrAuthError, etc.)
- Replace basic IPv6 validation with Python's ipaddress module
- Add HTTP request timeouts (30s total, 10s connect)
- Modernize development workflow with uv package manager
- Create FastMCP server with proper async/await patterns

New features:
- FastMCP server implementation with 12 DNS management tools
- Comprehensive Claude Desktop integration guide
- Enhanced error handling with specific exception types
- Professional README with badges and examples
- Complete testing suite with improvement validation

Documentation:
- CLAUDE.md: Consolidated project documentation
- CLAUDE_DESKTOP_SETUP.md: Step-by-step Claude Desktop setup guide
- Updated README.md with modern structure and uv-first approach
- Enhanced TESTING.md with FastMCP testing patterns

Development improvements:
- Updated all scripts to use uv run commands
- Smart development setup with uv/pip fallback
- Added comprehensive test coverage for new features
- PyPI-ready package configuration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-07-16 10:09:20 -06:00

37 lines
876 B
Python

#!/usr/bin/env python3
import asyncio
import sys
from fastmcp import FastMCP
print("TESTING ASYNC FASTMCP PATTERNS", file=sys.stderr)
# Create FastMCP server
mcp = FastMCP(name="async-test")
@mcp.tool
def sync_tool() -> str:
"""A synchronous test tool"""
return "Sync tool working"
@mcp.tool
async def async_tool() -> str:
"""An asynchronous test tool"""
await asyncio.sleep(0.1) # Simulate async work
return "Async tool working"
@mcp.tool
async def async_tool_with_params(name: str, count: int = 1) -> dict:
"""An async tool with parameters"""
await asyncio.sleep(0.1)
return {
"message": f"Hello {name}",
"count": count,
"status": "async success"
}
print("TOOLS REGISTERED, STARTING SERVER", file=sys.stderr)
if __name__ == "__main__":
print("RUNNING ASYNC TEST SERVER", file=sys.stderr)
mcp.run()