We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/pandeussilvae/mcp-odoo-panda'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
"""
FastMCP decorators module.
This module provides decorators for FastMCP handlers.
"""
import functools
import logging
from typing import Callable, Any, Optional, Dict, TypeVar, cast
logger = logging.getLogger(__name__)
T = TypeVar("T", bound=Callable[..., Any])
def mcp_handler(func: T) -> T:
"""
Decorator for MCP handlers.
Args:
func: Function to decorate
Returns:
Decorated function
"""
@functools.wraps(func)
async def wrapper(*args: Any, **kwargs: Any) -> Any:
try:
return await func(*args, **kwargs)
except Exception as e:
logger.error(f"Error in MCP handler: {str(e)}")
raise
return cast(T, wrapper)
def mcp_resource(func: T) -> T:
"""
Decorator for MCP resource handlers.
Args:
func: Function to decorate
Returns:
Decorated function
"""
@functools.wraps(func)
async def wrapper(*args: Any, **kwargs: Any) -> Any:
try:
return await func(*args, **kwargs)
except Exception as e:
logger.error(f"Error in MCP resource handler: {str(e)}")
raise
return cast(T, wrapper)
def mcp_tool(func: T) -> T:
"""
Decorator for MCP tool handlers.
Args:
func: Function to decorate
Returns:
Decorated function
"""
@functools.wraps(func)
async def wrapper(*args: Any, **kwargs: Any) -> Any:
try:
return await func(*args, **kwargs)
except Exception as e:
logger.error(f"Error in MCP tool handler: {str(e)}")
raise
return cast(T, wrapper)