mcp
Agent with MCP document workspace tools
mcp/mcp.plumb
(* An agent with access to a document workspace via MCP.
Demonstrates HTTP transport with bearer token authentication.
Run:
LDC_TOKEN=<your-token> plumb examples/mcp/mcp.plumb
Or interactively:
LDC_TOKEN=<your-token> chat examples/mcp/mcp.plumb
Then ask:
"Search for documents about compaction"
"Read the file notes/observations/OBS-005.md"
"What documents are in the workspace?" *)
let ldc = {
url: "https://leithdocs.com/ldc/mcp",
token_env: "LDC_TOKEN",
tools: ["read", "search", "grep"]
}
let assistant : !string -> !string = agent {
provider: "anthropic",
model: "claude-haiku-4-5",
prompt: "You are a research assistant with access to a document workspace via MCP tools. Use the available tools to find and read documents. Respond with a brief summary of what you found.",
mcp: [ldc],
runtime_context: true
}
let main : !string -> !string = plumb(input, output) {
spawn assistant(input, output)
}
mcp/mcp.py
"""MCP document workspace query.
Sends a query to an agent that has access to a document workspace
via MCP tools (read, search, grep).
Requires: ANTHROPIC_API_KEY, LDC_TOKEN
Usage:
ANTHROPIC_API_KEY=sk-... LDC_TOKEN=... python mcp.py
"""
import os
from pathlib import Path
import plumbing as pb
spec = Path(__file__).parent / "mcp.plumb"
query = "Search for documents about compaction"
results = pb.call_sync(
spec,
query,
auto_approve=True,
env={"LDC_TOKEN": os.environ.get("LDC_TOKEN", "")},
)
for result in results:
print(result)