Skip to main content
Glama
clsung

Taiwan Stock Agent

by clsung

list_resources

Access and list all available MCP resources, including templates and examples, to streamline data querying and analysis for the Taiwan stock market with Taiwan Stock Agent.

Instructions

List all available MCP resources with templates and examples

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Primary handler for the 'list_resources' tool. Decorated with @mcp.tool for registration and executes the logic to gather resource templates, cache stats, and subscriptions from resource_manager.
    @mcp.tool(name="list_resources", description="List all available MCP resources with templates and examples") async def list_resources_tool() -> Dict[str, Any]: """List all available MCP resources.""" try: templates = resource_manager.list_resource_templates() cache_stats = resource_manager.get_cache_stats() subscriptions = resource_manager.get_subscriptions() return { "resource_templates": templates, "cache_statistics": cache_stats, "active_subscriptions": subscriptions, "total_resources": len(templates), "_metadata": { "source": "tw-stock-agent", "timestamp": datetime.now().isoformat(), "data_type": "resource_discovery" } } except Exception as e: logger.error(f"Failed to list resources: {e}") return { "error": f"Failed to list resources: {str(e)}", "_metadata": { "source": "tw-stock-agent", "timestamp": datetime.now().isoformat(), "data_type": "resource_discovery", "has_error": True } }
  • Helper method in ResourceManager that formats and returns the list of available resource templates, central to the list_resources tool output.
    def list_resource_templates(self) -> List[Dict[str, Any]]: """List all available resource templates for discovery.""" templates = [] for uri_template, info in self.resource_templates.items(): templates.append({ "uriTemplate": uri_template, "name": uri_template.split("://")[1].replace("/", "_").replace("{", "").replace("}", ""), "description": info["description"], "mimeType": info["mimeType"], **info }) return templates
  • Helper method providing cache statistics included in the list_resources tool response.
    def get_cache_stats(self) -> Dict[str, Any]: """Get cache statistics.""" return { "size": len(self.cache), "max_size": self.cache.maxsize, "ttl": self.cache.ttl, "hits": getattr(self.cache, 'hits', 0), "misses": getattr(self.cache, 'misses', 0), "subscriptions": len(self.subscriptions) }
  • Helper method returning active subscriptions included in the list_resources tool response.
    def get_subscriptions(self) -> List[str]: """Get list of current resource subscriptions.""" return list(self.subscriptions)
  • Hardcoded resource templates dictionary in ResourceManager __init__, which serves as the data source for the resource_templates in list_resources tool output. Acts as schema definitions for available resources.
    self.resource_templates = { "stock://info/{stock_code}": { "description": "Get detailed information about a specific Taiwan stock", "mimeType": "application/json", "parameters": ["stock_code"], "examples": ["stock://info/2330", "stock://info/1101"] }, "stock://price/{stock_code}": { "description": "Get historical price data for a stock (default 1 month)", "mimeType": "application/json", "parameters": ["stock_code"], "examples": ["stock://price/2330", "stock://price/0050"] }, "stock://price/{stock_code}/{period}": { "description": "Get historical price data for a specific period", "mimeType": "application/json", "parameters": ["stock_code", "period"], "examples": ["stock://price/2330/1y", "stock://price/1101/3mo"] }, "stock://realtime/{stock_code}": { "description": "Get real-time trading data for a stock", "mimeType": "application/json", "parameters": ["stock_code"], "examples": ["stock://realtime/2330", "stock://realtime/0050"] }, "stock://analysis/{stock_code}": { "description": "Get technical analysis and trading signals", "mimeType": "application/json", "parameters": ["stock_code"], "examples": ["stock://analysis/2330", "stock://analysis/1101"] }, "market://overview": { "description": "Get Taiwan stock market overview and statistics", "mimeType": "application/json", "parameters": [], "examples": ["market://overview"] } }

Other Tools

Related Tools

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/clsung/tw-stock-agent'

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