Skip to content

docs(examples): add multi-server + agent integration guides#3

Merged
jieyao-MilestoneHub merged 8 commits into
mainfrom
docs/examples
Apr 15, 2026
Merged

docs(examples): add multi-server + agent integration guides#3
jieyao-MilestoneHub merged 8 commits into
mainfrom
docs/examples

Conversation

@jieyao-MilestoneHub
Copy link
Copy Markdown
Contributor

Summary

Adds examples/ with two scenarios so users can quickly bootstrap a multi-MCP architecture:

  • multi-server/ — scaffold 3 servers via mcp-forge new, orchestrate with docker-compose.yml, env template, shared Dockerfile, full walkthrough README
  • agent-integration/ — transport-choice guide (HTTP vs stdio) plus two framework blueprints:
    • anthropic-sdk/ — explicit agentic loop with anthropic SDK + mcp client (server-prefixed tool routing)
    • langchain-langgraph/MultiServerMCPClient + prebuilt create_react_agent

Docs-only change. No framework code touched. Agent-side agent.py files are clearly marked pseudo-code because the MCP client / LangChain-MCP adapter APIs are still in flux.

Split across 4 topical commits for reviewability:

  • db0270e multi-server scenario + top-level index
  • b169af0 agent-integration overview
  • 62b5a1d Anthropic SDK blueprint
  • 3f8fdce LangChain/LangGraph blueprint

Test plan

  • examples/README.md renders on GitHub and inter-doc links resolve
  • mcp-forge new search-mcp -o examples/multi-server scaffolds cleanly
  • docker-compose up --build in examples/multi-server/ brings up ports 8001/8002/8003 once the three packages are scaffolded
  • Reviewers confirm pseudo-code warning on each agent.py is prominent enough

jieyao-MilestoneHub and others added 8 commits April 11, 2026 01:02
- Fix mcp-forge-core README: github.com/mcp-forge/mcp-forge (404) →
  github.com/CoreNovus/mcp-forge
- Fix Quick Start example: mcp.run() → run_server(mcp) to use the
  mode-switching server factory
- Remove PLAN.md: documented Protocol-based architecture but code uses
  ABCs, template filenames and workflow structure were outdated

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Scaffold (mcp-forge-cli):
- Use SandboxedEnvironment instead of Environment to prevent Jinja2
  template introspection attacks via custom --templates directories
- Add path traversal guard in MCPServerScaffold.generate() — verify
  output stays within the intended parent directory
- Add validate_text_field() to reject unsafe characters (", \n, \r, \)
  in author/email/description fields before template interpolation
- Call validation in orchestrator before scaffolding

Providers (mcp-forge-core):
- InMemoryCache: add max_size parameter with oldest-first eviction to
  prevent unbounded memory growth in long-running dev servers
- InMemoryTelemetry: add max_metrics parameter with rolling window
- Default server_host from 0.0.0.0 to 127.0.0.1 in config.py and
  server_factory.py to prevent unintended network exposure in dev

AWS providers (mcp-forge-aws):
- Narrow exception handling: catch (ClientError, BotoCoreError) instead
  of bare Exception in DynamoDB and CloudWatch providers — let
  programming errors propagate instead of being silently swallowed
- CloudWatch: use asyncio.to_thread() for consistency with DynamoDB
  providers instead of loop.run_in_executor(lambda)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- bedrock_llm.py: remove no-op message conversion loop — the ternary
  and subsequent for-loop were both identity operations
- retry.py: extract _execute_with_retry() to eliminate duplicated retry
  loop between @Retry decorator and with_retry() function; log
  type(exc).__name__ instead of full exception message to avoid leaking
  sensitive data in retry warnings
- cli.py: fix version command — use proper __version__ import instead
  of hacky ScaffoldConfig.__module__.split('.')[0]
- test_scaffold.py: add encoding="utf-8" to all read_text() calls —
  fixes 2 pre-existing test failures on Windows cp950 locale caused by
  em-dash characters in generated server.py docstring

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Make the mcp SDK an invisible implementation detail of mcp-forge-core
so that generated servers never import from mcp.server.fastmcp directly.

- Re-export FastMCP from mcp_forge_core.__init__ — users can now write
  from mcp_forge_core import FastMCP for type annotations
- Update test_sample.py.j2 to use create_mcp_app() instead of directly
  importing FastMCP from the mcp SDK
- Remove redundant mcp>=1.0 dependency from pyproject.toml.j2 — it is
  already a transitive dependency via mcp-forge-core

When mcp SDK 2.0 ships, only server_factory.py needs updating — no
generated user code will break.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Adds examples/README.md as the scenario picker and examples/multi-server/
with a step-by-step walkthrough, docker-compose.yml for three scaffolded
servers on 8001/8002/8003, a shared Dockerfile, and an .env.example for
the common MCP_* knobs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Introduces examples/agent-integration/ with the transport-choice explainer
(http vs stdio), shared prerequisites, and a pointer to the two framework
sub-folders that follow in subsequent commits.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pseudo-code agent.py showing how to open an MCP ClientSession against
each of the three servers, flatten tool manifests into Anthropic
tool_use format with server-prefixed names, and run an agentic loop
with tool routing. Includes README with step-by-step usage and a
requirements.txt pinning the minimal deps.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Pseudo-code agent.py using langchain-mcp-adapters' MultiServerMCPClient
to aggregate tools from the three servers into a LangGraph prebuilt
ReAct agent. Includes README explaining when to pick this over the raw
Anthropic SDK approach and a requirements.txt with the LangChain stack.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@jieyao-MilestoneHub jieyao-MilestoneHub merged commit ccd44d4 into main Apr 15, 2026
7 checks passed
@jieyao-MilestoneHub jieyao-MilestoneHub deleted the docs/examples branch April 15, 2026 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant