Use this guide to connect AI clients (Windsurf, Cursor, Claude Desktop, Codex) to smallFactory via MCP.
Install web dependencies first (includes MCP runtime):
python3 -m pip install -r web/requirements.txtFrom the project root:
python3 sf.py web --port 8080By default:
- Web UI:
http://127.0.0.1:8080 - MCP endpoint:
http://127.0.0.1:8080/mcp
Repo selection is resolved automatically in this order:
--repoSF_DATAREPO.smallfactory.ymldefault_datarepo
Use --repo /ABS/PATH/... only when you want to pin a specific datarepo explicitly.
Your MCP URL depends on the web bind settings:
- If you run
python3 sf.py web --host 0.0.0.0 --port 8080, local clients still usually connect tohttp://127.0.0.1:8080/mcp. - If you change port, update client URL to match (
http://127.0.0.1:<PORT>/mcp). - If you set
SF_MCP_PATH, replace/mcpwith that path.
Quick health check:
curl -i -X POST http://127.0.0.1:8080/mcp \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' \
-d '{}'A JSON-RPC validation error (HTTP 400) is expected for {} and confirms MCP is reachable.
Use streamable HTTP:
{
"mcpServers": {
"smallfactory": {
"disabled": false,
"transport": "streamable-http",
"serverUrl": "http://127.0.0.1:8080/mcp"
}
}
}Notes:
- Use a tool-enabled chat mode (for example, Code mode) if you want
tools/call. - Some modes may only use resources; smallFactory exposes compatibility resources for those clients.
{
"mcpServers": {
"smallfactory": {
"transport": "streamable-http",
"serverUrl": "http://127.0.0.1:8080/mcp"
}
}
}{
"mcpServers": {
"smallfactory": {
"transport": "streamable-http",
"serverUrl": "http://127.0.0.1:8080/mcp"
}
}
}In Codex app settings, add MCP server:
- transport:
streamable-http - URL:
http://127.0.0.1:8080/mcp
Tool-first clients:
server_statusrepo_infoparts_inventory_list
Resource-first clients:
smallfactory://statussmallfactory://repo_infosmallfactory://parts/quantities
Use these as copy/paste prompts in your MCP client.
Call repo_info and return only datarepo_path.Use parts_inventory_list with {"limit": 200, "sort_by": "qty", "sort_dir": "asc"} and return a table of part, qty, status_bucket.Show parts likely to run out soon using parts_inventory_list with {"status_bucket":"critical","limit":200}.Create a DigiKey order for low-stock items needed to build 5 units of p_xyz.For part p_abc, list recent repair-related events from build_events_list with {"part_sfid":"p_abc","tags":["repair"],"limit":100}.What are the most common repair tags in the last 30 days? Use analytics_query grouped by tag.Resolve BOM for p_widget at max depth 3 using bom_resolved and summarize leaf parts.
Read resource smallfactory://statusRead resource smallfactory://repo_infoRead resource smallfactory://parts/quantities and show a low-stock table
-
POST /mcp 404:- Usually means app was started with
python3 web/app.py(Flask only). - Start with
python3 sf.py web ...instead.
- Usually means app was started with
-
Connected but tool calls fail:
- Client/session is likely resource-only.
- Use resource URIs above or switch to a tool-enabled mode/session.
-
Wrong repo appears in results:
- Always verify with
repo_infoorsmallfactory://repo_info. - Pin repo explicitly when starting:
--repo /ABS/PATH/....
- Always verify with