CMSIS-MCP  Version 0.0.0
Embedded MCP server with serial transport
 
Loading...
Searching...
No Matches
Automate the board

After adding tools to the firmware, as in the simple C example, start the Python bridge as described in the integration guide. It exposes the board's tools at http://127.0.0.1:8765/mcp.

Connect an AI harness

Add an MCP server entry to your AI harness's configuration, using Streamable HTTP and the Python bridge URL http://127.0.0.1:8765/mcp. The configuration format depends on the harness. If you change the bridge's address or port, use its corresponding /mcp URL.

Keep the bridge running so the harness can discover and call the firmware's tools. With the example firmware, the AI agent can discover setGain and call it with the numeric argument gain: 2.0.

Call tools from scripts

Scripts can also call board tools through the bridge using MCP JSON-RPC messages over HTTP. With the bridge running, save this Bash and curl example as board-tool.sh:

#!/usr/bin/env bash
set -euo pipefail
# Start the Python bridge first, then send HTTP requests to its MCP endpoint.
url=http://127.0.0.1:8765/mcp
http=(-fsS --max-time 30 -H 'Content-Type: application/json'
-H 'Accept: application/json, text/event-stream')
# Initialize MCP and extract the session ID from the HTTP response headers.
session_id=$(curl "${http[@]}" "$url" -D - -o /dev/null --data-binary \
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"bash-script","version":"1.0.0"}}}' \
| awk 'tolower($1) == "mcp-session-id:" {gsub("\r", "", $2); print $2}')
[[ -n "$session_id" ]] || { echo 'Missing MCP session ID' >&2; exit 1; }
http+=(-H "Mcp-Session-Id: $session_id" -H 'MCP-Protocol-Version: 2025-06-18')
# Complete initialization. This notification has no ID or response body.
curl "${http[@]}" "$url" --data-binary \
'{"jsonrpc":"2.0","method":"notifications/initialized"}'
# Set the board gain to 2.0. The gain argument is a JSON number.
curl "${http[@]}" "$url" --data-binary \
'{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"setGain","arguments":{"gain":2.0}}}'
printf '\n'
# Close this HTTP session; the shared bridge stays running.
curl "${http[@]}" "$url" -X DELETE -o /dev/null

Run bash board-tool.sh to set the gain to 2.0. This example assumes the board firmware defines a setGain tool with a numeric gain argument, as in the simple C example; the library does not register it automatically. Change the gain value in the final tools/call message to set another gain, and adjust url if needed. No tool discovery is performed.

The Python bridge forwards the tool call over serial and returns the board's result. The script prints the JSON response; check its error field or result.isError when using it in automated checks, since an MCP error can still have HTTP status 200. Only Bash, curl and awk are needed.

After initialization, reuse the same session ID and HTTP headers to call multiple tools. Send those calls before the final DELETE request, which closes the session.