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
| Name | Required | Description | Default |
|---|---|---|---|
| resource_uri | Yes |
Implementation Reference
- mcp_server.py:276-304 (handler)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 } }