Skip to main content
Glama

MCP Template

config.py1.9 kB
""" Example config resource implementation. """ import json from typing import Any import mcp.types as types from ..core.settings import Settings async def config_resource_handler(uri: str, settings: Settings) -> str: """ Example resource that returns server configuration. Args: uri: Resource URI (e.g., "config://server" or "config://registry") settings: Application settings Returns: JSON string containing the requested configuration """ # Parse resource type from URI resource_type = uri.split("://")[-1].split("/")[1] if "/" in uri else "all" if resource_type == "server": config = { "name": settings.server.name, "version": settings.server.version, "description": settings.server.description, "debug": settings.server.debug, } elif resource_type == "registry": config = { "enabled": settings.registry.enabled, "url": settings.registry.url, "heartbeat_interval": settings.registry.heartbeat.interval, } elif resource_type == "all": config = { "server": { "name": settings.server.name, "version": settings.server.version, "description": settings.server.description, }, "registry": { "enabled": settings.registry.enabled, }, "tools": { "enabled": settings.tools.enabled, }, } else: return json.dumps({"error": f"Unknown config type: {resource_type}"}) return json.dumps(config, indent=2) # Resource schema definition CONFIG_RESOURCE_SCHEMA = types.Resource( uri="config://example_config", name="Server Configuration", description="Access server configuration information", mimeType="application/json", )

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/riteshsonawala/mcp-template'

If you have feedback or need assistance with the MCP directory API, please join our Discord server