logfire_link
Generate a direct link to view specific trace details in the Logfire UI for analysis and debugging purposes.
Instructions
Creates a link to help the user to view the trace in the Logfire UI.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| trace_id | Yes | The trace ID to link to. |
Implementation Reference
- logfire_mcp/main.py:133-147 (handler)The handler function that creates a Logfire UI link for the specified trace_id using the logfire client.async def logfire_link( ctx: Context[ServerSession, MCPState], trace_id: Annotated[str, Field(description='The trace ID to link to.')], ) -> str: """Creates a link to help the user to view the trace in the Logfire UI.""" logfire_client = ctx.request_context.lifespan_context.logfire_client response = await logfire_client.client.get('/v1/read-token-info') read_token_info = cast(ReadTokenInfo, response.json()) organization_name = read_token_info['organization_name'] project_name = read_token_info['project_name'] url = logfire_client.client.base_url url = url.join(f'{organization_name}/{project_name}') url = url.copy_add_param('q', f"trace_id='{trace_id}'") return str(url)
- logfire_mcp/main.py:161-161 (registration)Registration of the 'logfire_link' tool with the MCP server.mcp.tool()(logfire_link)
- logfire_mcp/main.py:135-135 (schema)Input schema definition for the trace_id parameter using Pydantic Field.trace_id: Annotated[str, Field(description='The trace ID to link to.')],
- logfire_mcp/main.py:167-173 (helper)TypedDict used to type the read token info response in the handler.class ReadTokenInfo(TypedDict): token_id: str organization_id: str project_id: str organization_name: str project_name: str