Skip to main content

Agent for interacting with Langfuse Observability API

Project description

Langfuse Agent

API | MCP | Agent

PyPI - Version MCP Server PyPI - Downloads GitHub Repo stars GitHub forks GitHub contributors PyPI - License GitHub GitHub last commit (by committer) GitHub pull requests GitHub closed pull requests GitHub issues GitHub top language GitHub language count GitHub repo size GitHub repo file count (file type) PyPI - Wheel PyPI - Implementation

Version: 0.33.0

Documentation — Installation, deployment, usage across the API, CLI, and MCP interfaces, and guidance for provisioning the Langfuse platform are maintained in the official documentation.


Overview

Langfuse Agent is a production-grade Agent and Model Context Protocol (MCP) server designed to interface directly with the Langfuse LLM Engineering and Observability platform. It enables agentic models to query, create, and manage observability traces, datasets, prompt templates, and system configurations.


Key Features

  • Consolidated Action-Routed MCP Tools: Minimizes token overhead and eliminates tool bloat in LLM contexts by grouping 80+ methods into 4 optimized, togglable tool modules.
  • Enterprise-Grade Security: Comprehensive support for Eunomia policies, OIDC token delegation, and granular execution context tracking.
  • Integrated Graph Agent: Built-in Pydantic AI agent supporting the Agent Control Protocol (ACP) and standard Web interfaces (AG-UI).
  • Native Telemetry & Tracing: Out-of-the-box OpenTelemetry exports and native Langfuse tracing tracking every trace and span.

CLI or API

This agent wraps the Langfuse API. You can interact with it programmatically or via its integrated execution entrypoints.

Detailed instructions on how to use the underlying API wrappers, extended schema bindings, and developer SDK references are maintained in docs/index.md.


MCP

This server utilizes dynamic Action-Routed tools to optimize token overhead and maximize IDE compatibility.

Available MCP Tools

Auto-generated — do not edit between the markers below.

MCP Tool Toggle Env Var Description
langfuse_datasets LANGFUSE_DATASETSTOOL Perform langfuse_datasets operations.
langfuse_management LANGFUSE_MANAGEMENTTOOL Perform langfuse_management operations.
langfuse_observability LANGFUSE_OBSERVABILITYTOOL Perform langfuse_observability operations.
langfuse_prompts_models LANGFUSE_PROMPTS_MODELSTOOL Perform langfuse_prompts_models operations.

4 action-routed tools (default MCP_TOOL_MODE=condensed). Each is enabled unless its toggle is set false; set MCP_TOOL_MODE=verbose (or both) for the 1:1 per-operation surface. Auto-generated — do not edit.

Detailed tool schemas, parameter shapes, and validation constraints are preserved in docs/mcp.md.

Dynamic Tool Selection & Visibility

This MCP server supports dynamic toolset selection and visibility filtering at runtime. This allows you to restrict the set of exposed tools in order to prevent blowing up the LLM's context window.

You can configure tool filtering via multiple input channels:

  • CLI Arguments: Pass --tools or --toolsets (or their disabled counterparts --disabled-tools and --disabled-toolsets) during startup.
  • Environment Variables: Define standard environment variables:
    • MCP_ENABLED_TOOLS / MCP_DISABLED_TOOLS
    • MCP_ENABLED_TAGS / MCP_DISABLED_TAGS
  • HTTP SSE Request Headers: Pass custom headers during transport initialization:
    • x-mcp-enabled-tools / x-mcp-disabled-tools
    • x-mcp-enabled-tags / x-mcp-disabled-tags
  • HTTP SSE Request Query Parameters: Append query parameters directly to your transport connection URL:
    • ?tools=tool1,tool2
    • ?tags=tag1

When query strings or parameters are supplied, an LLM-free Knowledge Graph resolution layer (using DynamicToolOrchestrator) matches query intents against known tool tags, names, or descriptions, with safe fallback and automated 24-hour background cache refreshing.


MCP Configuration Examples

Install the slim [mcp] extra. All examples below install langfuse-agent[mcp] — the MCP-server extra that pulls only the FastMCP / FastAPI tooling (agent-utilities[mcp]). It deliberately excludes the heavy agent runtime (the epistemic-graph engine, pydantic-ai, dspy, llama-index, tree-sitter), so uvx/container installs are dramatically smaller and faster. Use the full [agent] extra only when you need the integrated Pydantic AI agent (see Installation).

stdio Transport (Recommended for local IDEs e.g., Cursor, Claude Desktop)

Configure your IDE's mcp.json to launch the MCP server via uvx:

{
  "mcpServers": {
    "langfuse-agent": {
      "command": "uvx",
      "args": [
        "--from",
        "langfuse-agent[mcp]",
        "langfuse-mcp"
      ],
      "env": {
        "LANGFUSE_BASE_URL": "http://localhost:8080",
        "LANGFUSE_TOKEN": "your_token_here"
      }
    }
  }
}

Streamable-HTTP Transport (Recommended for production deployments)

To run the server as a long-running Streamable-HTTP service:

{
  "mcpServers": {
    "langfuse-agent": {
      "url": "http://localhost:8004/langfuse-agent/mcp"
    }
  }
}

Deploying the Streamable-HTTP server via Docker:

docker run -d \
  --name langfuse-agent-mcp \
  -p 8004:8004 \
  -e TRANSPORT=streamable-http \
  -e PORT=8004 \
  -e LANGFUSE_BASE_URL="http://your-langfuse-instance:8080" \
  -e LANGFUSE_TOKEN="your_token" \
  knucklessg1/langfuse-agent:mcp

The :mcp tag is the slim MCP-server image (built from docker/Dockerfile --target mcp, installing langfuse-agent[mcp]). The default :latest tag is the full agent image (--target agent, langfuse-agent[agent]) which also bundles the Pydantic AI agent and the epistemic-graph engine — use it when you run langfuse-agent (the agent), not just the MCP server. See Container images.


Additional Deployment Options

langfuse-agent can also run as a local container (Docker / Podman / uv) or be consumed from a remote deployment. The Deployment guide has full, copy-paste mcp_config.json for all four transports — stdio, streamable-http, local container / uv, and remote URL:

  • Local container / uv — launch the server from mcp_config.json via uvx, docker run, or podman run, or point at a local streamable-http container by url.
  • Remote URL — connect to a server deployed behind Caddy at http://langfuse-mcp.arpa/mcp using the "url" key.

Agent

This repository features a fully integrated Pydantic AI Graph Agent. It communicates over the Agent Control Protocol (ACP) and interacts seamlessly with the Agent Web UI (AG-UI) and Terminal interface.

Running the Agent CLI

To start the interactive command-line agent:

# Set credentials
export LANGFUSE_BASE_URL="http://localhost:8080"
export LANGFUSE_TOKEN="your_token"

# Run the agent server
langfuse-agent --provider openai --model-id gpt-4o

Docker Compose Orchestration

The following docker/agent.compose.yml configures the Agent, Web UI, and Terminal Interface together:

version: '3.8'

services:
  langfuse-agent-mcp:
    image: knucklessg1/langfuse-agent:mcp
    container_name: langfuse-agent-mcp
    hostname: langfuse-agent-mcp
    restart: always
    env_file:
      - ../.env
    environment:
      - PYTHONUNBUFFERED=1
      - HOST=0.0.0.0
      - PORT=8004
      - TRANSPORT=streamable-http
    ports:
      - "8004:8004"
    healthcheck:
      test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8004/health')"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

  langfuse-agent-agent:
    image: knucklessg1/langfuse-agent:latest
    container_name: langfuse-agent-agent
    hostname: langfuse-agent-agent
    restart: always
    depends_on:
      - langfuse-agent-mcp
    env_file:
      - ../.env
    command: [ "langfuse-agent" ]
    environment:
      - PYTHONUNBUFFERED=1
      - HOST=0.0.0.0
      - PORT=9004
      - MCP_URL=http://langfuse-agent-mcp:8004/mcp
      - PROVIDER=${PROVIDER:-openai}
      - MODEL_ID=${MODEL_ID:-gpt-4o}
      - ENABLE_WEB_UI=True
      - ENABLE_OTEL=True
    ports:
      - "9004:9004"
    healthcheck:
      test: ["CMD", "python3", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:9004/health')"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 10s

Detailed graph node architecture explanations, custom skill configurations, and agentic trace guides are available in docs/agent.md.


Security & Governance

Built directly upon the enterprise-ready agent-utilities core, standard security parameters are fully supported:

Access Control & Policy Enforcement

  • Eunomia Policies: Fine-grained, policy-driven tool authorization. Supports none, local embedded (mcp_policies.json), or centralized remote modes.
  • OIDC Token Delegation: Compliant with RFC 8693 token exchange for flowing authenticating user credentials from Web UI / ACP → Agent → MCP.
  • Scoped Credentials: Execution context runs restricted to the specific caller identity.

Runtime Security Grid

Feature Functionality Enablement
Tool Guard Sensitivity inspection with human-in-the-loop validation Enabled by default
Prompt Injection Defense Input scanning, repetition monitoring, and recursive loop blocks Enabled by default
Context Safety Guard Stuck-loop detectors and contextual overflow preemptive alerts Enabled by default

Configuration & Environment Variables

The agent can be fully configured using environment variables or a .env file. Below is the list of all supported variables:

Core API & Credentials

Variable Description Default
LANGFUSE_BASE_URL Langfuse instance base URL. https://cloud.langfuse.com
LANGFUSE_PUBLIC_KEY Langfuse public API key. ""
LANGFUSE_SECRET_KEY Langfuse secret API key. ""
LANGFUSE_TOKEN Consolidated authentication token. ""

Server Configuration

Variable Description Default
HOST The hostname/address the server binds to. 0.0.0.0
PORT The port the server listens on. 8004
TRANSPORT The communication protocol (stdio, streamable-http, sse). stdio
AUTH_TYPE Server authentication strategy (key, delegated, none). key

Agent Customization

Variable Description Default
DEFAULT_AGENT_NAME Custom name displayed for the Pydantic AI Graph Agent. "Langfuse Agent"
AGENT_DESCRIPTION Short description of the agent's responsibilities. "AI agent for Langfuse Agent operations."
AGENT_SYSTEM_PROMPT Custom system instructions override for the agent. ""

Tool Toggle Switches

Individual tool modules can be enabled or disabled to minimize client context size. These names match the authoritative "Toggle Env Var" column in the Available MCP Tools table above:

  • LANGFUSE_OBSERVABILITYTOOL (Default: True): Toggles observation/tracing tools.
  • LANGFUSE_DATASETSTOOL (Default: True): Toggles datasets and annotation queue tools.
  • LANGFUSE_PROMPTS_MODELSTOOL (Default: True): Toggles prompt template and model connectivity tools.
  • LANGFUSE_MANAGEMENTTOOL (Default: True): Toggles comments, SCIM, and project management tools.

Installation

Pick the extra that matches what you want to run:

Extra Installs Use when
langfuse-agent[mcp] Slim MCP server only (agent-utilities[mcp] — FastMCP/FastAPI) You only run the MCP server (smallest install / image)
langfuse-agent[agent] Full agent runtime (agent-utilities[agent,logfire] — Pydantic AI + the epistemic-graph engine) You run the integrated agent
langfuse-agent[all] Everything (mcp + agent + logfire) Development / both surfaces
# MCP server only (recommended for tool hosting — slim deps)
uv pip install "langfuse-agent[mcp]"

# Full agent runtime (Pydantic AI + epistemic-graph engine)
uv pip install "langfuse-agent[agent]"

# Everything (development)
uv pip install "langfuse-agent[all]"      # or: python -m pip install "langfuse-agent[all]"

Container images (:mcp vs :agent)

One multi-stage docker/Dockerfile builds two right-sized images, selected by --target:

Image tag Build target Contents Entrypoint
knucklessg1/langfuse-agent:mcp --target mcp langfuse-agent[mcp]slim, no engine/pydantic-ai/dspy/llama-index/tree-sitter langfuse-mcp
knucklessg1/langfuse-agent:latest --target agent (default) langfuse-agent[agent]full agent runtime + epistemic-graph engine langfuse-agent
docker build --target mcp   -t knucklessg1/langfuse-agent:mcp    docker/   # slim MCP server
docker build --target agent -t knucklessg1/langfuse-agent:latest docker/   # full agent

Knowledge-graph database (epistemic-graph)

The full agent ([agent] / :latest) embeds the epistemic-graph engine (pulled in transitively via agent-utilities[agent]). For production — or to share one knowledge graph across multiple agents — run epistemic-graph as its own database container and point the agent at it instead of embedding it. Deployment recipes (single-node + Raft HA), connection config, and the full database architecture (with diagrams) are documented in the epistemic-graph deployment guide. The slim [mcp] server does not require the database.


Documentation

The complete documentation is published as the official documentation site and is the recommended reference for installation, deployment, and day-to-day operation.

Page Contents
Installation pip, source, extras, prebuilt Docker image
Deployment run the MCP and agent servers, Compose, Caddy + Technitium, env config
Usage the MCP tools, the LangfuseApi client, the CLI
Backing Platform deploy Langfuse with Docker
Overview the full tool surface and ecosystem role
Concepts concept registry (CONCEPT:LF-*)

Repository Owners

GitHub followers GitHub User's stars


Contribute

Contributions are welcome! Please ensure code quality by executing local checks before submitting pull requests:

  • Format code using ruff format .
  • Lint code using ruff check .
  • Validate type-safety with mypy .
  • Execute test suites using pytest

Deploy with agent-os-genesis

This package can be provisioned for you — skill-guided — by the agent-os-genesis universal skill (its single-package deploy mode): it picks your install method, seeds secrets to OpenBao/Vault (or .env), trusts your enterprise CA, registers the MCP server, and verifies it — the same machinery that stands up the whole Agent OS, narrowed to just this package. Ask your agent to "deploy langfuse-agent with agent-os-genesis".

Install mode Command
Bare-metal, prod (PyPI) uvx langfuse-mcp · or uv tool install langfuse-agent
Bare-metal, dev (editable) uv pip install -e ".[all]" · or pip install -e ".[all]"
Container, prod deploy knucklessg1/langfuse-agent:latest via docker-compose / swarm / podman / podman-compose / kubernetes
Container, dev (editable) deploy docker/compose.dev.yml (source-mounted at /src; edits live on restart)

Secrets are read-existing + seeded via vault_sync — you are only prompted for what's missing.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langfuse_agent-0.33.0.tar.gz (57.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langfuse_agent-0.33.0-py3-none-any.whl (64.7 kB view details)

Uploaded Python 3

File details

Details for the file langfuse_agent-0.33.0.tar.gz.

File metadata

  • Download URL: langfuse_agent-0.33.0.tar.gz
  • Upload date:
  • Size: 57.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for langfuse_agent-0.33.0.tar.gz
Algorithm Hash digest
SHA256 fdfd9d38b1892ec8e74dfad79473bdddf7837ee91cd11c021e1af0d97026ab0a
MD5 99188962ef50c8a1f14563220213c855
BLAKE2b-256 64eae992d8ee8d32534fbb63f95028e4ad635d5552c673199fda373beaf79fff

See more details on using hashes here.

File details

Details for the file langfuse_agent-0.33.0-py3-none-any.whl.

File metadata

File hashes

Hashes for langfuse_agent-0.33.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f5e97cf9fdbd97fb1becf4d33fb63402bb28bd0e27c24badaa9595b8a070c598
MD5 f605f669f279a53fc04d7d80cf0577a5
BLAKE2b-256 30e2ce3729d66d190bf2de30f37bdeaecfb145832d1a498d5795a10bd78a896a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page