|
|
||
|---|---|---|
| .. | ||
| README.md | ||
| main.py | ||
| requirements.txt | ||
| simple_server.py | ||
| utils.py | ||
README.md
PocketFlow MCP Demo
This project shows how to build an agent that performs addition using PocketFlow and Model Context Protocol (MCP). It presents a comparison between using MCP and basic function calling approaches.
Features
- Addition operations through a simple terminal interface
- Integration with Model Context Protocol (MCP)
- Comparison between MCP and direct function calling
How to Run
-
Set your API key:
export OPENAI_API_KEY="your-api-key-here"Or update it directly in
utils.py -
Install and run:
pip install -r requirements.txt python main.py
MCP vs Function Calling
To compare both approaches, this demo provides local function alternatives that don't require MCP:
- To use traditional function calling instead of MCP, replace:
get_tools()withlocal_get_tools()call_tool()withlocal_call_tool()
This allows you to see the difference between the two approaches while keeping the same workflow.
Function Calling
- Functions are directly embedded in application code
- Each new tool requires modifying the application
- Tools are defined within the application itself
MCP Approach
- Tools live in separate MCP servers
- Standard protocol for all tool interactions
- New tools can be added without changing the agent
- AI can interact with tools through a consistent interface
How It Works
flowchart LR
tools[GetToolsNode] -->|decide| decide[DecideToolNode]
decide -->|execute| execute[ExecuteToolNode]
The agent uses PocketFlow to create a workflow where:
- It takes user input about numbers
- Connects to the MCP server for addition operations
- Returns the result
Files
main.py: Implementation of the addition agent using PocketFlowutils.py: Helper functions for API calls and MCP integrationsimple_server.py: MCP server that provides the addition tool