Skip to main content

A Python framework for building multi-agent MCP servers

Project description

agent-mcp-framework

CI PyPI Docker Python 3.10+

A Python framework for building multi-agent MCP (Model Context Protocol) servers.

Compose multi-agent systems with sequential, parallel, conditional, and map-reduce pipeline patterns, agent lifecycle hooks, and structured outputs — and expose the result as MCP tools for Claude, VSCode, or any MCP-compatible client.

Features

  • Agent abstractionsAgent, LLMAgent, FunctionAgent with lifecycle hooks
  • Pipeline composition — Sequential, Parallel, Conditional, and MapReduce patterns
  • MCP integration — Expose agent pipelines as MCP tools over stdio or SSE
  • Output formatting — JSON, Markdown, and plain text output modes
  • CLI — Run servers and pipelines from the command line
  • Docker ready — Dockerfile, docker-compose, and container health checks
  • CI — GitHub Actions matrix (Python 3.10–3.13): lint, tests, Docker build

Installation

pip install agent-mcp-framework

Quick Start

from agent_mcp_framework import Agent, AgentContext, AgentResult, SequentialPipeline, AgentMCPServer


class AnalyzerAgent(Agent):
    async def run(self, context: AgentContext) -> AgentResult:
        code = context.get("code", "")
        issues = []
        if len(code.splitlines()) > 500:
            issues.append("File exceeds 500 lines — consider splitting")
        if "import *" in code:
            issues.append("Wildcard imports detected")
        context.set("issues", issues)
        return AgentResult(success=True, output={"issues": issues, "count": len(issues)})


class ScorerAgent(Agent):
    async def run(self, context: AgentContext) -> AgentResult:
        issues = context.get("issues", [])
        score = max(0, 100 - len(issues) * 15)
        return AgentResult(success=True, output={"score": score, "grade": "A" if score >= 90 else "B" if score >= 70 else "C"})


# Compose agents into a pipeline
pipeline = SequentialPipeline("code-review", agents=[
    AnalyzerAgent("analyzer", description="Find code issues"),
    ScorerAgent("scorer", description="Score code quality"),
])

# Expose as an MCP server
server = AgentMCPServer("code-review-server", description="Multi-agent code review")
server.add_pipeline_tool(
    pipeline,
    name="review_code",
    description="Analyze code quality and return a score",
    parameters={"code": str},  # the input schema MCP clients see
)

if __name__ == "__main__":
    server.run()  # Starts MCP server on stdio

Docker

# Build and run locally
docker compose up --build

# Or build manually
docker build -t agent-mcp-framework .
docker run -p 8080:8080 agent-mcp-framework

Health check endpoints:

Endpoint Purpose
GET / Service info
GET /health Liveness probe
GET /ready Readiness probe

Agent Types

Agent — Base class

Implement run() to define your agent's logic.

LLMAgent — Claude-powered agent

Built-in Anthropic client with complete() helper for LLM calls.

FunctionAgent — Quick inline agents

Wrap any async function as an agent without subclassing.

Pipeline Patterns

Pattern Description
SequentialPipeline Run agents one after another, each seeing updated context
ParallelPipeline Run agents concurrently with optional concurrency limits
ConditionalPipeline Route to agents based on a condition function
MapReducePipeline Split work, fan out, and reduce results

CLI

# Start an MCP server
agent-mcp serve my_project.server

# Run a pipeline directly
agent-mcp run my_project.pipeline --input '{"code": "import *"}'

# Show framework info
agent-mcp info

Project Infrastructure

  • Dockerfile — Multi-stage build with health checks
  • docker-compose.yml — Local development
  • .github/workflows/ci.yml — CI pipeline (lint, test, Docker build)

License

MIT

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

agent_mcp_framework-0.2.0.tar.gz (21.0 kB view details)

Uploaded Source

Built Distribution

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

agent_mcp_framework-0.2.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

Details for the file agent_mcp_framework-0.2.0.tar.gz.

File metadata

  • Download URL: agent_mcp_framework-0.2.0.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for agent_mcp_framework-0.2.0.tar.gz
Algorithm Hash digest
SHA256 0fbf9e625d08931a3af18700643ad5c8871a7c590b8ea56429d4a9107d13d800
MD5 c7a574959aa6374728b36792cf45eefe
BLAKE2b-256 0c69f50138387f36abfb79718a7c2601a403b8d6d4dc06b6a397d4fcf0863a18

See more details on using hashes here.

File details

Details for the file agent_mcp_framework-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_mcp_framework-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2568c0f3f43de060bb84f35ddf525ffce40cae31bfbcf559436d61a60db900c0
MD5 808776a6ab63c681401aba93db068cb5
BLAKE2b-256 c8c1f23a6b527410758fafeb64eb83cd44cf005c00640c99319f6473e1f57193

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