Skip to main content
Glama
pydantic

Logfire MCP Server

Official

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
NameRequiredDescriptionDefault
trace_idYesThe trace ID to link to.

Implementation Reference

  • 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)
  • Registration of the 'logfire_link' tool with the MCP server.
    mcp.tool()(logfire_link)
  • Input schema definition for the trace_id parameter using Pydantic Field.
    trace_id: Annotated[str, Field(description='The trace ID to link to.')],
  • 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

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/pydantic/logfire-mcp'

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