fetch_token_broadcasts
Fetch broadcasts for a specific token ID to get token-related broadcast data in JSON format.
Instructions
Fetch broadcasts for a specific token
Args:
token_id: Vector token ID
Returns:
JSON string with token broadcastsInput Schema
| Name | Required | Description | Default |
|---|---|---|---|
| token_id | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- vector_server.py:402-445 (handler)Main handler function for fetch_token_broadcasts tool. Sends a GraphQL query to fetch token broadcasts with optional pagination and sorting parameters.
@mcp.tool(name="fetch_token_broadcasts") async def fetch_token_broadcasts( token_id: str, ctx: Context = None ) -> str: """Fetch broadcasts for a specific token Args: token_id: Vector token ID Returns: JSON string with token broadcasts """ if ctx: ctx.info(f"Fetching broadcasts for token {token_id}...") # Hardcoded variables as requested variables = { "id": token_id, "after": None, "first": 100, "sortBy": "Time", "sortDirection": "Desc" } payload = { "query": TOKEN_BROADCASTS_QUERY, "variables": variables } async with httpx.AsyncClient(verify=False) as client: try: response = await client.post( API_URL, json=payload, headers=HEADERS ) response.raise_for_status() return response.text except Exception as e: error_message = f"Error fetching token broadcasts: {str(e)}" if ctx: ctx.error(error_message) return error_message - vector_server.py:247-271 (schema)GraphQL query schema used by fetch_token_broadcasts. Defines the TokenBroadcastsQuery with parameters for ID, pagination (after, first), sorting (sortBy, sortDirection), and returns broadcast messages.
TOKEN_BROADCASTS_QUERY = """ query TokenBroadcastsQuery( $id: ID! $after: String $first: Int = 100 $sortBy: TokenBroadcastSortBy $sortDirection: TokenBroadcastSortDirection ) { tokenBroadcasts( id: $id after: $after first: $first sortBy: $sortBy sortDirection: $sortDirection ) { edges { node { broadcast { message } } } } } """ - vector_server.py:402-402 (registration)Registration of the fetch_token_broadcasts tool via the @mcp.tool decorator.
@mcp.tool(name="fetch_token_broadcasts")