Copyright (c) 2025, Software Tree
This guide explains how to interact with an ORMCP server running in HTTP mode using curl or other HTTP clients.
Start ORMCP Server in HTTP mode (the Gilhari microservice must already be running at GILHARI_BASE_URL, otherwise ORMCP stops at start-up with a message naming the address it checked):
ormcp-server --transport http --port 8080When it is ready, you'll see output like:
🟢 ORMCP server v0.7.x starting in HTTP mode on 127.0.0.1:8080...
INFO: Uvicorn running on http://127.0.0.1:8080 (Press CTRL+C to quit)
First, establish a connection and initialize the MCP session:
curl -X POST \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"1","method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl-client","version":"1.0.0"}}}' \
"http://127.0.0.1:8080/mcp"Key Points:
- Use the
/mcpendpoint, without a trailing slash (/mcp/answers with a307redirect, whichcurl -X POSTdoes not follow) - Include both
application/jsonandtext/event-streamin Accept header - The server will return a session ID in the
mcp-session-idheader
Expected Response (shortened):
event: message
data: {"jsonrpc":"2.0","id":"1","result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{"listChanged":true},...},"serverInfo":{"name":"ORMCPServerDemo","version":"0.7.x"},"instructions":"..."}}
serverInfo.version is the ORMCP Server version (since 0.7.0).
Save the mcp-session-id from the response headers (e.g., c97b99b7b9b343bd8cf590f5d5a40367).
After successful initialization, send the required initialized notification:
curl -X POST \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-H "mcp-session-id: YOUR_SESSION_ID_HERE" \
-d '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
"http://127.0.0.1:8080/mcp"Note: This request has no id field since it's a notification, not a request expecting a response.
Now you can discover what tools are available:
curl --max-time 10 \
-X POST \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-H "mcp-session-id: YOUR_SESSION_ID_HERE" \
-d '{"jsonrpc":"2.0","id":"2","method":"tools/list"}' \
"http://127.0.0.1:8080/mcp"Use the tools/call method to execute available tools:
curl --max-time 10 \
-X POST \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-H "mcp-session-id: YOUR_SESSION_ID_HERE" \
-d '{"jsonrpc":"2.0","id":"3","method":"tools/call","params":{"name":"TOOL_NAME","arguments":{"param1":"value1"}}}' \
"http://127.0.0.1:8080/mcp"A successful call returns the tool's output as text in result.content (and again in result.structuredContent.result), with "isError": false. A failing call also returns a result, with "isError": true and the error message as text — for example:
data: {"jsonrpc":"2.0","id":"3","result":{"content":[{"type":"text","text":"Error calling tool 'query': HTTP 404: Error during query: ..."}],"isError":true}}
| Method | Description | Example Usage |
|---|---|---|
tools/list |
List all available tools | See step 3 above |
tools/call |
Execute a specific tool | See step 4 above |
resources/list |
List available resources | Similar to tools/list |
prompts/list |
List available prompts | Similar to tools/list |
Solution: Include both content types in Accept header:
-H "Accept: application/json, text/event-stream"
Solution:
- Ensure you've initialized first and captured the session ID
- Include the session ID in subsequent requests:
-H "mcp-session-id: YOUR_SESSION_ID_HERE"
Solution: Send the notifications/initialized notification after initialization but before making other requests.
Solution: Use /mcp without a trailing slash.
Cause: ORMCP's Host/Origin protection (on by default) rejects requests whose Host header is not trusted — for example when ORMCP is reached through a tunnel, a proxy or a Docker host name.
Solution: Add the host name to ALLOWED_HOSTS (comma-separated) before starting ORMCP, e.g. ALLOWED_HOSTS=host.docker.internal. See the Troubleshooting Guide.
This is normal for Server-Sent Events. Use --max-time 10 to set a timeout, or press Ctrl+C to cancel.
For browser-based interaction, you can use JavaScript:
// Initialize
fetch('http://127.0.0.1:8080/mcp', {
method: 'POST',
headers: {
'Accept': 'application/json, text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"jsonrpc": "2.0",
"id": "1",
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"capabilities": {},
"clientInfo": {"name": "browser-client", "version": "1.0.0"}
}
})
})
.then(response => {
const sessionId = response.headers.get('mcp-session-id');
// Use sessionId for subsequent requests
});Note: a page served from another origin is also subject to ORMCP's Origin check; add that origin to ALLOWED_ORIGINS if needed.
- The Command Prompt does not accept single quotes or
\line continuations: put each command on one line, use double quotes around the JSON, and escape the inner quotes with\" - Add
--max-time 10to prevent hanging connections
For example, the initialize request in the Command Prompt (-i shows the response headers, including mcp-session-id):
curl -i -X POST http://127.0.0.1:8080/mcp -H "Content-Type: application/json" -H "Accept: application/json, text/event-stream" -d "{\"jsonrpc\":\"2.0\",\"id\":1,\"method\":\"initialize\",\"params\":{\"protocolVersion\":\"2025-06-18\",\"capabilities\":{},\"clientInfo\":{\"name\":\"curl\",\"version\":\"1\"}}}"
This completes the basic interaction pattern with your MCP server in HTTP mode.