Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions examples/mcp_agent_server/asyncio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ uv run client.py

This will:

1. Start the basic_agent_server.py as a subprocess
1. Start the agent server (main.py) as a subprocess
2. Connect to the server
3. Run the BasicAgentWorkflow
4. Monitor and display the workflow status
Expand All @@ -137,10 +137,10 @@ You can also run the server and client separately:
1. In one terminal, start the server:

```
uv run basic_agent_server.py
uv run main.py

# Optionally, run with the example custom FastMCP settings
uv run basic_agent_server.py --custom-fastmcp-settings
uv run main.py --custom-fastmcp-settings
```

2. In another terminal, run the client:
Expand Down Expand Up @@ -299,7 +299,7 @@ npx @modelcontextprotocol/inspector \
uv \
--directory /path/to/mcp-agent/examples/mcp_agent_server/asyncio \
run \
basic_agent_server.py
main.py
```

This will launch the MCP Inspector UI where you can:
Expand All @@ -323,7 +323,7 @@ To use this server with Claude Desktop:
"--directory",
"/path/to/mcp-agent/examples/mcp_agent_server/asyncio",
"run",
"basic_agent_server.py"
"main.py"
]
}
```
Expand Down Expand Up @@ -354,7 +354,7 @@ mcp:

## Code Structure

- `basic_agent_server.py` - Defines the workflows and creates the MCP server
- `main.py` - Defines the workflows and creates the MCP server
- `client.py` - Example client that connects to the server and runs workflows
- `mcp_agent.config.yaml` - Configuration for MCP servers and execution engine
- `mcp_agent.secrets.yaml` - Contains API keys (not included in repository)
Expand Down
8 changes: 2 additions & 6 deletions examples/mcp_agent_server/asyncio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,7 @@ async def sampling_demo(topic: str, app_ctx: Optional[AppContext] = None) -> str
# Register a simple nested server that uses sampling in its get_haiku tool
nested_name = "nested_sampling"
nested_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__), "..", "shared", "nested_sampling_server.py"
)
os.path.join(os.path.dirname(__file__), "nested_sampling_server.py")
)
_app.context.config.mcp.servers[nested_name] = MCPServerSettings(
name=nested_name,
Expand Down Expand Up @@ -168,9 +166,7 @@ async def elicitation_demo(

nested_name = "nested_elicitation"
nested_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__), "..", "shared", "nested_elicitation_server.py"
)
os.path.join(os.path.dirname(__file__), "nested_elicitation_server.py")
)
_app.context.config.mcp.servers[nested_name] = MCPServerSettings(
name=nested_name,
Expand Down
22 changes: 14 additions & 8 deletions examples/mcp_agent_server/temporal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ To run this example, you'll need to:
4. In another terminal, start the MCP server:

```bash
uv run basic_agent_server.py
uv run main.py
```
Comment on lines +144 to 145
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Renamed entrypoint to main.py — looks good; please sweep for stale references.
Docs reflect the rename; confirm no remaining references to basic_agent_server.py across the repo.


🏁 Script executed:

#!/bin/bash
# Find stale references to the old entrypoint name(s)
rg -nP -S '\bbasic[_-]agent[_-]server(\.py)?\b|BasicAgentServer' -g '!**/node_modules/**'

Length of output: 148


🏁 Script executed:

#!/bin/bash
set -euo pipefail

PATTERN=$'\bbasic[_-]agent[_-]server(\.py)?\b|basicAgentServer|BasicAgentServer'
echo "Searching repo for stale entrypoint references..."
if command -v rg >/dev/null 2>&1; then
  rg -nP --hidden --no-ignore -S --ignore-case --glob '!node_modules/**' "$PATTERN" || true
else
  echo "rg not found; falling back to git grep"
  git grep -n --ignore-case -e 'basic_agent_server' -e 'basic-agent-server' -e 'basicAgentServer' || true
fi

Length of output: 198


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "PWD: $(pwd)"
echo "Top-level listing:"
ls -la || true

echo "Git repo root:"
git rev-parse --show-toplevel || true

echo "Git status (short):"
git status --porcelain --untracked-files=all || true

echo "Count files under repo (first 200 shown):"
find . -type f | wc -l || true
find . -type f -print | sed -n '1,200p' || true

echo "rg --version:"
rg --version || true

echo "Running rg --debug to see why files are skipped..."
PATTERN='\bbasic[_-]agent[_-]server(\.py)?\b|basicAgentServer|BasicAgentServer'
rg --debug -nP --hidden --no-ignore -S --ignore-case --glob '!node_modules/**' "$PATTERN" || true

echo "Fallback: git grep for common variants"
git grep -n --ignore-case -e 'basic_agent_server' -e 'basic-agent-server' -e 'basicAgentServer' || true

Length of output: 181560


Stale references to basic_agent_server remain — update to main.py

Update these files (docs, examples, templates, and CLI code) to reference main.py (and rename worker script references where appropriate):

  • docs/cli-reference.mdx
  • examples/mcp_agent_server/README.md
  • examples/mcp_agent_server/asyncio/README.md
  • examples/mcp_agent_server/asyncio/client.py
  • examples/mcp_agent_server/asyncio/main.py
  • examples/mcp_agent_server/temporal/README.md
  • examples/mcp_agent_server/temporal/client.py
  • examples/mcp_agent_server/temporal/main.py
  • examples/mcp_agent_server/temporal/basic_agent_server_worker.py
  • examples/usecases/reliable_conversation/CLAUDE.md
  • src/mcp_agent/cli/commands/init.py
  • src/mcp_agent/cli/commands/quickstart.py
  • src/mcp_agent/cli/commands/serve.py
  • src/mcp_agent/data/templates/basic_agent_server.py
🤖 Prompt for AI Agents
In examples/mcp_agent_server/temporal/README.md around lines 144-145, there are
stale references to basic_agent_server; update this and all listed files to
reference main.py instead (and rename any worker script references where
appropriate). Specifically, replace occurrences of "basic_agent_server" with
"main.py" (or adjust to the new worker script name), update docs/CLI examples
and templates to call main.py, rename or update
examples/mcp_agent_server/temporal/basic_agent_server_worker.py to the new
worker filename and adjust imports/usages, and update src/mcp_agent/cli/*
commands and template src/mcp_agent/data/templates/basic_agent_server.py to
reflect the new filenames/entrypoints so all examples, docs, and CLI commands
consistently reference main.py.


5. In a fourth terminal, run the client:
Expand Down Expand Up @@ -215,7 +215,7 @@ npx @modelcontextprotocol/inspector \
uv \
--directory /path/to/mcp-agent/examples/mcp_agent_server/temporal \
run \
basic_agent_server.py
main.py
```

This will launch the MCP Inspector UI where you can:
Expand All @@ -239,7 +239,7 @@ To use this server with Claude Desktop:
"--directory",
"/path/to/mcp-agent/examples/mcp_agent_server/temporal",
"run",
"basic_agent_server.py"
"main.py"
]
}
```
Expand All @@ -250,7 +250,7 @@ To use this server with Claude Desktop:

## Code Structure

- `basic_agent_server.py` - Defines the workflows and creates the MCP server
- `main.py` - Defines the workflows and creates the MCP server
- `basic_agent_server_worker.py` - Sets up the Temporal worker to process workflow tasks
- `client.py` - Example client that connects to the server and runs workflows
- `mcp_agent.config.yaml` - Configuration for MCP servers and the Temporal execution engine
Expand All @@ -271,8 +271,8 @@ class PauseResumeWorkflow(Workflow[str]):
print(f"Workflow is pausing, workflow_id: {self.id}, run_id: {self.run_id}")

# Wait for the resume signal - this will pause the workflow
await app.context.executor.signal_bus.wait_for_signal(
Signal(name="resume", workflow_id=self.id, run_id=self.run_id),
await app.context.executor.wait_for_signal(
signal_name="resume", workflow_id=self.id, run_id=self.run_id,
)

print("Signal received, workflow is resuming...")
Expand Down Expand Up @@ -318,10 +318,16 @@ async with gen_client("basic_agent_server", context.server_registry) as server:
)

# The workflow will pause - to resume it, send the resume signal
run_id = pause_result.content[0].text
execution = WorkflowExecution(
**json.loads(pause_result.content[0].text)
)

run_id = execution.run_id
workflow_id = execution.workflow_id

await server.call_tool(
"workflows-resume",
arguments={"workflow_id": "PauseResumeWorkflow", "run_id": run_id}
arguments={"workflow_id": workflow_id, "run_id": run_id}
)
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from mcp_agent.executor.temporal import create_temporal_worker_for_app

from basic_agent_server import app
from main import app

# Initialize logging
logging.basicConfig(level=logging.INFO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)


# Create a single FastMCPApp instance (which extends MCPApp)
app = MCPApp(
name="basic_agent_server",
Expand Down Expand Up @@ -193,9 +194,7 @@ async def call_nested_sampling(topic: str) -> str:
)
nested_name = "nested_sampling"
nested_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__), "..", "shared", "nested_sampling_server.py"
)
os.path.join(os.path.dirname(__file__), "nested_sampling_server.py")
)
app_ctx.config.mcp.servers[nested_name] = MCPServerSettings(
name=nested_name,
Expand Down Expand Up @@ -233,9 +232,7 @@ async def call_nested_elicitation(action: str) -> str:
)
nested_name = "nested_elicitation"
nested_path = os.path.abspath(
os.path.join(
os.path.dirname(__file__), "..", "shared", "nested_elicitation_server.py"
)
os.path.join(os.path.dirname(__file__), "nested_elicitation_server.py")
)
app_ctx.config.mcp.servers[nested_name] = MCPServerSettings(
name=nested_name,
Expand Down
31 changes: 31 additions & 0 deletions examples/mcp_agent_server/temporal/nested_elicitation_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
from pydantic import BaseModel
from mcp.server.fastmcp import FastMCP
from mcp.server.elicitation import elicit_with_validation, AcceptedElicitation

mcp = FastMCP("Nested Elicitation Server")


class Confirmation(BaseModel):
confirm: bool


@mcp.tool()
async def confirm_action(action: str) -> str:
"""Ask the user to confirm an action via elicitation."""
ctx = mcp.get_context()
res = await elicit_with_validation(
ctx.session,
message=f"Do you want to {action}?",
schema=Confirmation,
)
if isinstance(res, AcceptedElicitation) and res.data.confirm:
return f"Action '{action}' confirmed by user"
return f"Action '{action}' declined by user"


def main():
mcp.run()


if __name__ == "__main__":
main()
40 changes: 40 additions & 0 deletions examples/mcp_agent_server/temporal/nested_sampling_server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from mcp.server.fastmcp import FastMCP
from mcp.types import ModelPreferences, ModelHint, SamplingMessage, TextContent

mcp = FastMCP("Nested Sampling Server")


@mcp.tool()
async def get_haiku(topic: str) -> str:
"""Use MCP sampling to generate a haiku about the given topic."""
result = await mcp.get_context().session.create_message(
messages=[
SamplingMessage(
role="user",
content=TextContent(
type="text", text=f"Generate a quirky haiku about {topic}."
),
)
],
system_prompt="You are a poet.",
max_tokens=100,
temperature=0.7,
model_preferences=ModelPreferences(
hints=[ModelHint(name="gpt-4o-mini")],
costPriority=0.1,
speedPriority=0.8,
intelligencePriority=0.1,
),
)

if isinstance(result.content, TextContent):
return result.content.text
return "Haiku generation failed"


def main():
mcp.run()


if __name__ == "__main__":
main()
3 changes: 2 additions & 1 deletion examples/mcp_agent_server/temporal/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
mcp-agent @ file://../../../ # Link to the local mcp-agent project root

# Additional dependencies specific to this example
temporalio
openai
temporalio
Loading