Skip to main content
Glama
rwxproject
by rwxproject
system.py2.49 kB
""" System Resources Module Provides system-related resources such as version information and server status. This module demonstrates migrating the existing version resource to the new structure. """ from fastmcp import FastMCP from .base import StaticResource from ..config.settings import get_settings class SystemResources(StaticResource): """ Collection of system-related resources. Provides version information and other system data that was originally in the main.py file. """ def __init__(self): super().__init__(name="system") # Initialize with version from settings settings = get_settings() self.set_data({"version": settings.version}) def register_with_mcp(self, mcp: FastMCP) -> None: """ Register system resources with the FastMCP instance. Args: mcp: The FastMCP instance to register with """ # Register the version resource @mcp.resource("config://version") def get_version(): """Get the current version of the MCP server.""" self._log_resource_call("get_version") return self.get_data()["version"] # Register additional system info resource @mcp.resource("system://info") def get_system_info(): """Get system information about the MCP server.""" self._log_resource_call("get_system_info") settings = get_settings() return { "version": settings.version, "server_name": settings.server_name, "environment": settings.environment, "transport": settings.transport, "host": settings.host, "port": settings.port } self.logger.info("Registered system resources: config://version, system://info") def get_version(self) -> str: """ Direct method for getting version (can be used internally). Returns: The server version """ return self.get_data()["version"] def update_version(self, new_version: str) -> None: """ Update the version information. Args: new_version: The new version string """ data = self.get_data() data["version"] = new_version self.set_data(data) self.logger.info(f"Updated version to: {new_version}")

Latest Blog Posts

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/rwxproject/mcp-server-template'

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