Agent package for communicating with Stirling PDF via REST APIs.
Project description
Stirling PDF Agent
CLI or API | MCP | Agent
Version: 1.0.1
Documentation — Installation, deployment, usage across the MCP, API, and CLI interfaces, and guidance for provisioning the Stirling PDF service are maintained in the official documentation.
📚 Table of Contents
- Overview
- Key Features
- Installation
- Quick Start & Usage Examples
- MCP Server Mode
- Agent Mode
- Environment Variables Reference
- Security & Governance
- Developer & Contribute Guidelines
- Documentation
Overview
Stirling PDF Agent is a production-grade Agent and Model Context Protocol (MCP) server designed to interface directly with Stirling PDF via REST APIs. It provides seamless capability to manipulate, edit, and overlay PDFs (e.g. adding watermarks) programmatically or using large language models.
Key Features
- Consolidated Action-Routed MCP Tools: Minimizes token overhead and eliminates tool bloat in LLM contexts by grouping methods into 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.
Installation
Pick the extra that matches what you want to run:
| Extra | Installs | Use when |
|---|---|---|
stirlingpdf-agent[mcp] |
Slim MCP server only (agent-utilities[mcp] — FastMCP/FastAPI) |
You only run the MCP server (smallest install / image) |
stirlingpdf-agent[agent] |
Full agent runtime (agent-utilities[agent,logfire] — Pydantic AI + the epistemic-graph engine) |
You run the integrated agent |
stirlingpdf-agent[all] |
Everything (mcp + agent + logfire) |
Development / both surfaces |
# MCP server only (recommended for tool hosting — slim deps)
uv pip install "stirlingpdf-agent[mcp]"
# Full agent runtime (Pydantic AI + epistemic-graph engine)
uv pip install "stirlingpdf-agent[agent]"
# Everything (development)
uv pip install "stirlingpdf-agent[all]" # or: python -m pip install "stirlingpdf-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/stirlingpdf-agent:mcp |
--target mcp |
stirlingpdf-agent[mcp] — slim, no engine/pydantic-ai/dspy/llama-index/tree-sitter |
stirlingpdf-mcp |
knucklessg1/stirlingpdf-agent:latest |
--target agent (default) |
stirlingpdf-agent[agent] — full agent runtime + epistemic-graph engine |
stirlingpdf-agent |
docker build --target mcp -t knucklessg1/stirlingpdf-agent:mcp docker/ # slim MCP server
docker build --target agent -t knucklessg1/stirlingpdf-agent:latest docker/ # full agent
docker/mcp.compose.yml runs the slim :mcp server; docker/agent.compose.yml runs the
agent (:latest) with a co-located :mcp sidecar.
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.
Quick Start & Usage Examples
Using the underlying Stirling PDF Client wrapper directly in Python:
from stirlingpdf_agent.api_client import StirlingPdfApi
# Initialize the Stirling PDF client
client = StirlingPdfApi(
base_url="http://localhost:8080",
token="your-stirling-pdf-api-key",
verify=True
)
# Example action: Add a watermark to an existing PDF
response = client.add_watermark(
filepath="input.pdf",
watermarkText="CONFIDENTIAL",
percentOfPage=30,
opacity=0.5,
rotation=45
)
# Save output PDF bytes
with open("watermarked_output.pdf", "wb") as f:
f.write(response.data)
MCP Server Mode
This server utilizes dynamic Action-Routed tools to optimize token overhead and maximize IDE compatibility.
Available MCP Tools
The table below is auto-generated from the MCP server — do not edit by hand.
Condensed action-routed tools (default — MCP_TOOL_MODE=condensed)
| MCP Tool | Toggle Env Var | Description |
|---|---|---|
pdf_action |
PDFTOOL |
Execute any Stirling PDF API action dynamically. |
Verbose 1:1 API-mapped tools (MCP_TOOL_MODE=verbose or both)
1 per-operation tools — one per public API method (click to expand)
| MCP Tool | Toggle Env Var | Description |
|---|---|---|
stirlingpdf_add_watermark |
WATERMARK_CLIENTTOOL |
Add a watermark to a PDF file. |
1 action-routed tool(s) (default) · 1 verbose 1:1 tool(s). Each is enabled unless its <DOMAIN>TOOL toggle is set false; MCP_TOOL_MODE selects the surface (condensed default · verbose 1:1 · both). Auto-generated — do not edit.
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
--toolsor--toolsets(or their disabled counterparts--disabled-toolsand--disabled-toolsets) during startup. - Environment Variables: Define standard environment variables:
MCP_ENABLED_TOOLS/MCP_DISABLED_TOOLSMCP_ENABLED_TAGS/MCP_DISABLED_TAGS
- HTTP SSE Request Headers: Pass custom headers during transport initialization:
x-mcp-enabled-tools/x-mcp-disabled-toolsx-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 installstirlingpdf-agent[mcp]— the MCP-server extra that pulls only the FastMCP / FastAPI tooling (agent-utilities[mcp]). It deliberately excludes the heavy agent runtime (pydantic-ai, the epistemic-graph engine,dspy,llama-index), souvx/ container installs are far smaller. Use the full[agent]extra only when you need the integrated Pydantic AI agent.
stdio Transport (local IDEs — Cursor, Claude Desktop, VS Code)
{
"mcpServers": {
"stirlingpdf-mcp": {
"command": "uvx",
"args": [
"--from",
"stirlingpdf-agent[mcp]",
"stirlingpdf-mcp"
],
"env": {
"MCP_TOOL_MODE": "condensed",
"PDFTOOL": "True",
"STIRLINGPDF_AGENT_VERIFY": "True",
"STIRLINGPDF_API_KEY": "",
"STIRLINGPDF_TOKEN": "",
"STIRLINGPDF_URL": "http://localhost:8080"
}
}
}
}
Streamable-HTTP Transport (networked / production)
{
"mcpServers": {
"stirlingpdf-mcp": {
"command": "uvx",
"args": [
"--from",
"stirlingpdf-agent[mcp]",
"stirlingpdf-mcp",
"--transport",
"streamable-http",
"--port",
"8000"
],
"env": {
"TRANSPORT": "streamable-http",
"HOST": "0.0.0.0",
"PORT": "8000",
"MCP_TOOL_MODE": "condensed",
"PDFTOOL": "True",
"STIRLINGPDF_AGENT_VERIFY": "True",
"STIRLINGPDF_API_KEY": "",
"STIRLINGPDF_TOKEN": "",
"STIRLINGPDF_URL": "http://localhost:8080"
}
}
}
}
Alternatively, connect to a pre-deployed Streamable-HTTP instance by url:
{
"mcpServers": {
"stirlingpdf-mcp": {
"url": "http://localhost:8000/stirlingpdf-mcp/mcp"
}
}
}
Deploying the Streamable-HTTP server via Docker:
docker run -d \
--name stirlingpdf-mcp-mcp \
-p 8000:8000 \
-e TRANSPORT=streamable-http \
-e HOST=0.0.0.0 \
-e PORT=8000 \
-e MCP_TOOL_MODE=condensed \
-e PDFTOOL=True \
-e STIRLINGPDF_AGENT_VERIFY=True \
-e STIRLINGPDF_API_KEY="" \
-e STIRLINGPDF_TOKEN="" \
-e STIRLINGPDF_URL=http://localhost:8080 \
knucklessg1/stirlingpdf-agent:mcp
Auto-generated from the code-read env surface (MCP_TOOL_MODE + package vars) — do not edit.
Additional Deployment Options
stirlingpdf-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.jsonviauvx,docker run, orpodman run, or point at a local streamable-http container byurl. - Remote URL — connect to a server deployed behind Caddy at
http://stirlingpdf-mcp.arpa/mcpusing the"url"key.
Agent Mode
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 STIRLINGPDF_URL="http://localhost:8080"
export STIRLINGPDF_API_KEY="your-api-key"
# Run the agent server
stirlingpdf-agent --provider openai --model-id gpt-4o
Docker Compose Orchestration
version: '3.8'
services:
stirlingpdf-agent-mcp:
image: knucklessg1/stirlingpdf-agent:latest
container_name: stirlingpdf-agent-mcp
hostname: stirlingpdf-agent-mcp
restart: always
env_file:
- .env
environment:
- PYTHONUNBUFFERED=1
- HOST=0.0.0.0
- PORT=8000
- TRANSPORT=streamable-http
ports:
- "8000:8000"
stirlingpdf-agent-agent:
image: knucklessg1/stirlingpdf-agent:latest
container_name: stirlingpdf-agent-agent
hostname: stirlingpdf-agent-agent
restart: always
depends_on:
- stirlingpdf-agent-mcp
env_file:
- .env
command: [ "stirlingpdf-agent" ]
environment:
- PYTHONUNBUFFERED=1
- HOST=0.0.0.0
- PORT=9004
- MCP_URL=http://stirlingpdf-agent-mcp:8000/mcp
- PROVIDER=${PROVIDER:-openai}
- MODEL_ID=${MODEL_ID:-gpt-4o}
- ENABLE_WEB_UI=True
- ENABLE_OTEL=True
ports:
- "9004:9004"
Environment Variables
Package environment variables
| Variable | Example | Description |
|---|---|---|
HOST |
0.0.0.0 |
|
PORT |
8000 |
|
TRANSPORT |
stdio |
options: stdio, streamable-http, sse |
ENABLE_OTEL |
True |
|
OTEL_EXPORTER_OTLP_ENDPOINT |
http://localhost:8080/api/public/otel |
|
OTEL_EXPORTER_OTLP_PUBLIC_KEY |
pk-... |
|
OTEL_EXPORTER_OTLP_SECRET_KEY |
sk-... |
|
OTEL_EXPORTER_OTLP_PROTOCOL |
http/protobuf |
|
EUNOMIA_TYPE |
none |
options: none, embedded, remote |
EUNOMIA_POLICY_FILE |
mcp_policies.json |
|
EUNOMIA_REMOTE_URL |
http://eunomia-server:8000 |
|
PDFTOOL |
True |
|
STIRLINGPDF_URL |
http://localhost:8080 |
|
STIRLINGPDF_API_KEY |
— | |
STIRLINGPDF_TOKEN |
— | alternate to STIRLINGPDF_API_KEY (bearer token) |
STIRLINGPDF_AGENT_VERIFY |
True |
|
STIRLINGPDF_SSL_VERIFY |
True |
alternate to STIRLINGPDF_AGENT_VERIFY (TLS cert verification) |
Inherited agent-utilities variables (apply to every connector)
| Variable | Example | Description |
|---|---|---|
MCP_TOOL_MODE |
condensed |
Tool surface: condensed |
MCP_ENABLED_TOOLS |
— | Comma-separated tool allow-list |
MCP_DISABLED_TOOLS |
— | Comma-separated tool deny-list |
MCP_ENABLED_TAGS |
— | Comma-separated tag allow-list |
MCP_DISABLED_TAGS |
— | Comma-separated tag deny-list |
MCP_CLIENT_AUTH |
— | Outbound MCP auth (oidc-client-credentials for fleet calls) |
OIDC_CLIENT_ID |
— | OIDC client id (service-account auth) |
OIDC_CLIENT_SECRET |
— | OIDC client secret (service-account auth) |
DEBUG |
False |
Verbose logging |
PYTHONUNBUFFERED |
1 |
Unbuffered stdout (recommended in containers) |
MCP_URL |
http://localhost:8000/mcp |
URL of the MCP server the agent connects to |
PROVIDER |
openai |
LLM provider for the agent |
MODEL_ID |
gpt-4o |
Model id for the agent |
ENABLE_WEB_UI |
True |
Serve the AG-UI web interface |
17 package + 14 inherited variable(s). Auto-generated from .env.example + the shared agent-utilities set — do not edit.
Reference
Stirling PDF Agent utilizes both package-specific environment configurations and standard security settings inherited from the agent-utilities system core.
Stirling PDF Agent Configs
PDFTOOL(bool, default:True): Toggles the dynamic PDF action tool registration.STIRLINGPDF_URL(str, default:http://localhost:8080): The base endpoint of the external Stirling PDF API service.STIRLINGPDF_API_KEY(str): API connection token/secret used to authenticate REST requests.STIRLINGPDF_AGENT_VERIFY(bool, default:True): Toggles SSL certificate verification during REST requests.
Inherited agent-utilities Configs
TRANSPORT(str, default:stdio): Server transport type. Options:stdio,sse,streamable-http.HOST(str, default:0.0.0.0): Network host interface to bind the HTTP server.PORT(int, default:8000): Port to listen on.ENABLE_OTEL(bool, default:False): Enables OpenTelemetry tracing integration.ALLOWED_CLIENT_REDIRECT_URIS(str): Comma-separated list of approved redirect URLs for authentication loops.AUTH_TYPE(str): Server authentication mode configurations.EUNOMIA_TYPE(str, default:none): Policy configuration enforcement. Options:none,embedded,remote.EUNOMIA_POLICY_FILE(str): Path to local JSON configuration policy maps.EUNOMIA_REMOTE_URL(str): Target URL for remote auth policy coordination.OAUTH_BASE_URL(str): Base OAuth service endpoint.OAUTH_UPSTREAM_AUTH_ENDPOINT(str): Upstream OAuth service authorization endpoint.OAUTH_UPSTREAM_CLIENT_ID(str): Client application identity ID.OAUTH_UPSTREAM_CLIENT_SECRET(str): Client secret credential token.OAUTH_UPSTREAM_TOKEN_ENDPOINT(str): Remote OAuth token resolution endpoint.
Security & Governance
Built directly upon the enterprise-ready agent-utilities core, standard security parameters are fully supported:
- Eunomia Policies: Fine-grained, policy-driven tool authorization. Supports
none, localembedded(mcp_policies.json), or centralizedremotemodes. - 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.
| Feature Guard | Functionality | Status |
|---|---|---|
| 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 |
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
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 StirlingPdfApi client, the CLI |
| Backing Platform | deploy Stirling PDF with Docker |
| Overview | the agent-package pattern and tool routing |
| Concepts | concept registry (CONCEPT:STIRLINGPDF-*) |
AGENTS.md is the canonical contributor/agent guidance.
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 stirlingpdf-agent with agent-os-genesis".
| Install mode | Command |
|---|---|
| Bare-metal, prod (PyPI) | uvx stirlingpdf-mcp · or uv tool install stirlingpdf-agent |
| Bare-metal, dev (editable) | uv pip install -e ".[all]" · or pip install -e ".[all]" |
| Container, prod | deploy knucklessg1/stirlingpdf-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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stirlingpdf_agent-1.0.1.tar.gz.
File metadata
- Download URL: stirlingpdf_agent-1.0.1.tar.gz
- Upload date:
- Size: 38.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bd35e25a2cb1b8b89b2fc276287842480929a02c14077fd88d3358250c1fd00
|
|
| MD5 |
5a27d9c5e7f1a95596f2ce9e9ef775b4
|
|
| BLAKE2b-256 |
7f1d98332e69675abe039b26dd1e749d727eaf723e3757a2c3887a88e76dc194
|
File details
Details for the file stirlingpdf_agent-1.0.1-py3-none-any.whl.
File metadata
- Download URL: stirlingpdf_agent-1.0.1-py3-none-any.whl
- Upload date:
- Size: 39.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83e1402d11b0a37996016f4cdeba0e2743be3f40ad00afccc9876a1e676b11c7
|
|
| MD5 |
760cb0df65439cfa21fe6a43d601f4be
|
|
| BLAKE2b-256 |
cbcd0b8b3ff95cbe6f1bfb1e58c7c3dbc26eb80d878e945fdbe3dac534646598
|