LO

Logfire Archived STDIO MCP Server

Explore this archived STDIO MCP server repository; it is no longer being updated.

Quick Install
npx -y @pydantic/logfire-mcp

Overview

This repository contains an archived STDIO-based MCP (Model Context Protocol) server implementation originally developed for Logfire. The server provides a minimal transport that communicates over standard input/output using a JSON-lines format that follows MCP conventions. It’s designed to let tools and model-driven agents exchange structured requests and responses using a local process boundary (stdin/stdout), which is useful for prototyping, testing, and integrating tooling into agent workflows.

Note that this repository is archived and no longer actively maintained. Logfire now hosts a remote MCP server that receives updates and improvements more frequently. Use this archive if you need a lightweight, local STDIO reference implementation or to inspect how a simple MCP transport can be implemented. For production usage or the latest features, consult the remote MCP server and official documentation.

Features

  • Lightweight STDIO transport: communicate with agents or tools via standard input and output using JSON Lines.
  • Simple JSON-based message format suitable for routing MCP messages (requests, responses, events).
  • Local tool adapter pattern for connecting command-line tools to an MCP-capable client or model agent.
  • Easy to clone and run locally for experimentation and debugging.
  • Minimal external dependencies; suitable as a learning/reference implementation.

Installation / Configuration

Clone and run from source, or install directly from the GitHub repository for convenience.

Clone the repo:

git clone https://github.com/pydantic/logfire-mcp.git
cd logfire-mcp

Install with pip (install from repository):

pip install git+https://github.com/pydantic/logfire-mcp.git

Run the STDIO MCP server from the repository (example):

# Run as a module if the package exposes a console entrypoint
python -m logfire_mcp.server

If you prefer running the repository code directly:

# from the repo root (adjust path if needed)
python src/logfire_mcp/server.py

Environment variables commonly used in development (example):

export LOGFIRE_MCP_LOG_LEVEL=info
export LOGFIRE_MCP_DEBUG=false

Systemd unit example to run the server as a local service:

[Unit]
Description=Logfire STDIO MCP Server
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/python -m logfire_mcp.server
WorkingDirectory=/opt/logfire-mcp
Restart=on-failure
Environment=LOGFIRE_MCP_LOG_LEVEL=info

[Install]
WantedBy=multi-user.target

Note: Because this repository is archived, package names, module paths, and entrypoints may vary. Check the code in the cloned repo for the exact module or script to run.

Available Resources

  • Repository (archive): https://github.com/pydantic/logfire-mcp
  • Documentation & migration guide: https://logfire.pydantic.dev/docs/how-to-guides/mcp-server/
  • Community support: Logfire Slack (see docs for invite) and [email protected]

If you use this archive to learn or prototype, consider migrating to Logfire’s remote MCP server for an actively maintained implementation and feature improvements.

Protocol / Message Overview

The STDIO MCP server exchanges JSON messages separated by newlines (JSON Lines). Typical message fields you will encounter:

FieldTypeDescription
idstringUnique identifier for request/response correlation
typestringMessage type (e.g., “request”, “response”, “event”)
toolstringName of tool to invoke or that produced the message
inputobjectPayload for a request (tool input)
outputobjectPayload for a response (tool output)
errorobjectError information if the request failed

Example inbound request (JSON-line):

{"id":"1234","type":"request","tool":"shell.exec","input":{"cmd":"echo hello"}}

Example response (JSON-line):

{"id":"1234","type":"response","tool":"shell.exec","output":{"stdout":"hello\n","exit_code":0}}

When building clients or tool adapters for this server, implement a simple loop that reads a line from stdin, parses JSON, processes the request, then writes a JSON response with a trailing newline to stdout.

Use Cases

  • Local tool integration: Wrap a CLI tool with an MCP-compatible adapter so a model agent can call it. For example, expose a local database query tool or a shell execution wrapper that accepts structured inputs and returns structured outputs.
  • Rapid prototyping: Use the STDIO transport to prototype MCP message flows without network or authentication complexity. Handy for tests and demos.
  • Debugging & inspection: Because the transport uses human-readable JSON Lines, it’s easy to log, replay, and inspect interactions between an agent and tools.
  • Educational reference: Study how a minimal MCP implementation handles message framing, request/response correlation, and error reporting.
  • Integration tests: Spawn the STDIO MCP server as a subprocess in test suites to simulate tool behavior for model-driven workflows.

Concrete example — a toy shell tool adapter in Python:

import sys, json, subprocess

for line in sys.stdin:
    msg = json.loads(line)
    if msg.get("type") != "request":
        continue
    req_id = msg["id"]
    cmd = msg["input"].get("cmd")
    try:
        out = subprocess.check_output(cmd, shell=True, text=True, stderr=subprocess.STDOUT)
        resp = {"id": req_id, "type": "response", "output": {"stdout": out, "exit_code": 0}}
    except subprocess.CalledProcessError as e:
        resp = {"id": req_id, "type": "response", "output": {"stdout": e.output, "exit_code": e.returncode}, "error": {"message": str(e)}}
    print(json.dumps(resp), flush=True)

Notes & Migration

This repository is archived and will not receive updates. For the latest features, improved tooling, and production readiness, refer to Logfire’s remote MCP server and the official documentation: https://logfire.pydantic.dev/docs/how-to-guides/mcp-server/. Use this archive for reference, learning, or isolated experiments only.