Skip to main content
Glama
clsung

Taiwan Stock Agent

by clsung

subscribe_resource

Subscribe to Taiwan stock market resource updates for real-time data caching and notification alerts on specific stocks or market information.

Instructions

Subscribe to resource updates for caching and notifications

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resource_uriYes

Implementation Reference

  • The handler function for the 'subscribe_resource' MCP tool. It subscribes to the specified resource URI using resource_manager and returns the subscription status along with active subscriptions and metadata.
    @mcp.tool(name="subscribe_resource",
              description="Subscribe to resource updates for caching and notifications")
    async def subscribe_resource_tool(resource_uri: str) -> Dict[str, Any]:
        """Subscribe to resource updates."""
        try:
            success = resource_manager.subscribe_to_resource(resource_uri)
            return {
                "resource_uri": resource_uri,
                "subscribed": success,
                "active_subscriptions": resource_manager.get_subscriptions(),
                "_metadata": {
                    "source": "tw-stock-agent",
                    "timestamp": datetime.now().isoformat(),
                    "data_type": "resource_subscription"
                }
            }
        except Exception as e:
            logger.error(f"Failed to subscribe to resource {resource_uri}: {e}")
            return {
                "resource_uri": resource_uri,
                "subscribed": False,
                "error": str(e),
                "_metadata": {
                    "source": "tw-stock-agent",
                    "timestamp": datetime.now().isoformat(),
                    "data_type": "resource_subscription",
                    "has_error": True
                }
            }

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