Skip to main content
Glama
README.md
# Muse Glimmer + MCP + Langfuse (local)

A minimal [Pydantic AI](https://ai.pydantic.dev) agent that:

- runs **`muse-glimmer`** (Meta's 30B agentic model) through a **local Ollama** instance,
- has **MCP enabled**: a local [FastMCP](https://fastmcp.com) server (`mcp_server.py`) is attached as a stdio subprocess, exposing `get_weather`, `get_current_time`, and `list_ollama_models` as agent tools,
- sends full traces (model requests, tool calls, outputs) to a **local Langfuse** instance for observability.

## Prerequisites

- [Ollama](https://ollama.com) running with the model pulled:
  ```bash
  ollama pull muse-glimmer
  ```
- A local Langfuse instance (e.g. via `docker compose` from the Langfuse repo) reachable at `http://localhost:3000`.
- [uv](https://docs.astral.sh/uv/) (or use `python3 -m venv` + `pip`).

## Setup

```bash
cp .env.example .env   # then fill in your Langfuse keys
uv sync                # installs pydantic-ai, fastmcp, langfuse, ...
```

`.env`:

```env
LANGFUSE_PUBLIC_KEY=pk-lf-...
LANGFUSE_SECRET_KEY=sk-lf-...
LANGFUSE_BASE_URL=http://localhost:3000
LANGFUSE_HOST=http://localhost:3000

OLLAMA_BASE_URL=http://localhost:11434/v1
OLLAMA_MODEL=muse-glimmer
```

## Run

```bash
uv run python agent.py
```

The agent answers three demo prompts, calling MCP tools as needed:

```text
šŸ§‘  User: What is the weather in Paris today?
šŸ¤–  Agent: Weather in Paris: clear skies, 22°C, humidity 51%.

šŸ§‘  User: What time is it in Tokyo right now?
šŸ¤–  Agent: The current time in Asia/Tokyo is 2026-08-25 21:04:33 JST.

šŸ§‘  User: Which Ollama models are available locally?
šŸ¤–  Agent: NAME  ID  SIZE  MODIFIED ...
```

## Observability (Langfuse)

Open <http://localhost:3000> → **Traces**. Each run produces traces named
`muse-glimmer-mcp-agent`, with spans for model requests (input/output tokens)
and each MCP tool call — inspect inputs, outputs, latencies, and costs.

## Expose the agent as an MCP server

`agent_mcp_server.py` flips the architecture around: the agent itself becomes
an **MCP server** exposing one tool — `ask_agent(prompt)` — to any MCP client
(Claude Desktop, VS Code, Cursor, another Pydantic AI agent, ...). Each call
runs `muse-glimmer` via Ollama, still has the inner MCP tools, and is traced
to Langfuse.

### Run the server

```bash
uv run python agent_mcp_server.py
```

### Client configuration

Point any MCP client at this server using your `uv`-managed venv's Python
(`uv run --project <repo> python` also works). Examples:

**Claude Desktop** — `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "muse-glimmer-agent": {
      "command": "/home/d3lee/.local/bin/uv",
      "args": ["run", "--project", "/home/d3lee/my-repos/pydantic-ai-mcp-server-sample", "python", "agent_mcp_server.py"]
    }
  }
}
```

**VS Code** — `.vscode/mcp.json`:

```json
{
  "servers": {
    "muse-glimmer-agent": {
      "type": "stdio",
      "command": "uv",
      "args": ["run", "--project", "/home/d3lee/my-repos/pydantic-ai-mcp-server-sample", "python", "agent_mcp_server.py"]
    }
  }
}
```

**Cursor** — `.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "muse-glimmer-agent": {
      "command": "uv",
      "args": ["run", "--project", "/home/d3lee/my-repos/pydantic-ai-mcp-server-sample", "python", "agent_mcp_server.py"]
    }
  }
}
```

## Layout

| File                | Purpose                                                        |
| ------------------- | -------------------------------------------------------------- |
| `agent.py`          | Pydantic AI agent: Ollama model + MCP capability + Langfuse    |
| `mcp_server.py`     | FastMCP server (stdio) exposing the local tools                |
| `agent_mcp_server.py`| Exposes the agent itself as an MCP server (`ask_agent` tool)  |
| `.env`              | Langfuse + Ollama configuration                                |
# pydantic-ai-mcp-server-sample

TDQS

B3.3/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or misselection. The tool 'ask_agent' has a clearly distinct purpose as the sole entry point for questioning the agent.

Naming Consistency5/5

The single tool name 'ask_agent' follows a consistent verb_noun pattern, aligned with its singular function. Naming is clear and predictable.

Tool Count3/5

The server has only one tool, which feels thin but is appropriate for its narrow purpose of asking a question. It is not an extreme mismatch, but it borders on insufficient for broader agent workflows.

Completeness5/5

The domain is defined as asking the Muse Glimmer agent a question, and the single tool fully covers this operation. There are no obvious gaps within the stated scope.

Maintenance

ActivityMaintained
ResponsivenessSyncing