Add MCP server for PTZ app with FastMCP interface#1
Conversation
|
@saumya-pailwan A few questions:
|
|
@plebbyd Great questions! Let me clarify: 1. Regarding the commits: No collaboration with Dario on this specific work - these are my commits only. The issue happened because I was pushing code from the H100 cluster where the All the MCP server implementation, including:
was developed independently as part of exploring agentic camera control architecture. 2. Usage of the MCP server: The MCP server provides two complementary deployment options, depending on the use case: 1: Standalone PTZ MCP Server (Current Implementation) The Deployment: # On the edge node with camera access
python camera_mcp_server.py \
--username camera_user \
--password camera_pass \
--cameraip 130.202.23.153This exposes tools at
Usage from Detection Pipeline: # Original approach (direct camera control)
camera = CameraControl(ip, user, password)
camera.absolute_control(pan=45, tilt=0, zoom=1)
image = camera.snap_shot()
# Through MCP server
from mcp_client import MCPClient
mcp_client = MCPClient("http://localhost:8000")
mcp_client.move_absolute(pan=45, tilt=0, zoom=1)
image_bytes = mcp_client.take_snapshot()Usage with LLM Agents: # Claude/GPT can now control the camera
llm_prompt = """
You have access to these camera control tools:
- get_position() -> returns current pan/tilt/zoom
- move_absolute(pan, tilt, zoom) -> moves camera
- take_snapshot() -> captures image
Task: Scan the area for people by rotating the camera.
"""
# Agent makes decisions and calls tools through MCP2. Integration with Sage-MCP ServerThe PTZ camera tools can be integrated into the main Sage-MCP server, making camera control available alongside other Sage tools (data queries, job submission, etc.). Once integrated, users could interact via: Cursor/Claude: HTTP API: curl -X POST http://localhost:8000/mcp \
-H "Content-Type: application/json" \
-d '{
"tool": "get_ptz_position",
"params": {
"camera_ip": "130.202.23.153",
"username": "admin",
"password": "secret"
}
}'Python MCP Client: from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
async def control_camera():
server_params = StdioServerParameters(
command="python",
args=["sage_mcp.py"]
)
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
result = await session.call_tool(
"get_ptz_position",
{
"camera_ip": "130.202.23.153",
"username": "admin",
"password": "secret"
}
)
print(f"Current position: {result}")Design Decisions After implementing this MCP abstraction, I developed the PlantNet species identification workflow which demonstrated that:
The MCP architecture would be particularly valuable for:
Additional Context: |
This adds the MCP server (sage_mcp.py) and integrates job submission logic tailored for the PTZ object detection pipeline. Includes custom submit_ptz_app_job() and SAGE-compatible configurations.