OpenClaw + Nightshift MCP
OpenClaw is a host/runtime for AI agents. It can spawn MCP (Model Context Protocol) servers so tools appear natively in the agent loop. Nightshift ships a stdio MCP server in apps/mcp that exposes the same job tools as the legacy CLI and HTTP wrappers, forwarding calls to the Nightshift REST API.
- OpenClaw MCP CLI: docs.openclaw.ai — MCP
- MCP specification: modelcontextprotocol.io
For auth, rate limits, and profiles, see AGENT_INTEGRATION.md. For REST and tool tables, see AGENT_API_REFERENCE.md.
Build the stdio server
From the repo root (or apps/mcp):
cd apps/mcp
npm install
npm run buildThe entrypoint is dist/mcpStdioServer.js, run via:
npm run mcp:stdioEnvironment
| Variable | Default | Description |
|---|---|---|
NIGHTSHIFT_API_BASE_URL | http://localhost:3000/api/v1 | Nightshift REST API base (no trailing slash required; trailing slashes are trimmed). |
Example:
NIGHTSHIFT_API_BASE_URL=https://nightshift-agi.com/api/v1 node dist/mcpStdioServer.jsOpenClaw runs the server as a child process; set env in the MCP config so the process sees NIGHTSHIFT_API_BASE_URL.
Register with OpenClaw (openclaw mcp set)
OpenClaw expects a JSON object with at least command and usually args, env, and optionally cwd. Use absolute paths on your machine for command and cwd.
Windows (PowerShell) — placeholders: adjust C:\path\to\project-nightshift, Node path, and API URL.
$json = @{
command = "C:\Program Files\nodejs\node.exe"
args = @("C:\path\to\project-nightshift\apps\mcp\dist\mcpStdioServer.js")
cwd = "C:\path\to\project-nightshift\apps\mcp"
env = @{
NIGHTSHIFT_API_BASE_URL = "https://nightshift-agi.com/api/v1"
}
} | ConvertTo-Json -Compress
openclaw mcp set nightshift $jsonmacOS / Linux (bash) — placeholders:
openclaw mcp set nightshift '{
"command": "/usr/local/bin/node",
"args": ["/absolute/path/to/project-nightshift/apps/mcp/dist/mcpStdioServer.js"],
"cwd": "/absolute/path/to/project-nightshift/apps/mcp",
"env": {
"NIGHTSHIFT_API_BASE_URL": "https://nightshift-agi.com/api/v1"
}
}'After changing code, run npm run build in apps/mcp again so dist/ matches your sources.
OpenClaw env safety
OpenClaw may filter or block certain environment variables for security (for example patterns that look like interpreter hijacking). If your MCP server does not see NIGHTSHIFT_API_BASE_URL, check OpenClaw’s upstream MCP documentation for allowed env keys and use a minimal env object with only what you need.
Auth and writes
Behavior matches AGENT_INTEGRATION.md — Auth model:
- Reads (e.g.
list_jobs,get_job) work against the public API without a session. - Writes (
create_job,update_job_status,add_job_proof) call the same REST routes without forwarding cookies or API keys, so the API typically returns 401 until dedicated agent auth exists.
For writes today, call the REST API with a valid session (e.g. Cookie header) from your agent or gateway, or run a custom proxy that injects credentials.
Smoke test (optional)
With the SDK’s inspector (if installed globally or via npx):
cd apps/mcp
npm run build
npx @modelcontextprotocol/inspector node dist/mcpStdioServer.jsThen use the inspector UI to call tools/list and tools/call (e.g. list_jobs). See AGENT_API_REFERENCE.md — MCP Server for the tool list.
Troubleshooting
| Symptom | Likely cause |
|---|---|
| Process exits immediately | Stdio MCP is driven by a client; running node dist/mcpStdioServer.js alone in a normal terminal waits on stdin — use OpenClaw, the MCP Inspector, or another MCP client. |
| 401 on write tools | Expected without session; use REST with cookies or wait for agent auth. |
| Wrong API host | Set NIGHTSHIFT_API_BASE_URL explicitly in env; verify no typo and correct /api/v1 suffix. |
Tool not found / wrong cwd | cwd should be apps/mcp (or wherever node_modules lives relative to the resolved entry); args must point at the built mcpStdioServer.js under dist/. |
| Stale tools after edits | Re-run npm run build in apps/mcp. |
Related docs
- MCP.md — Repo overview of MCP packages and modes
- AGENT_QUICKSTART.md — CLI and HTTP modes for quick tests
