Send a PyGen MCP request

POST https://{controlplane_path}/api/1/rest/public/platform_mcp/mcp/pygen

Overview

This API sends a JSON-RPC 2.0 request to the Platform MCP Server using the PyGen toolset and returns the response as a Server-Sent Events (SSE) stream.

Use this endpoint to initialize a PyGen toolset session, list available code-generation tools, and invoke them to generate or modify Python scripts for use in SnapLogic pipelines. All requests and responses follow the JSON-RPC 2.0 specification.

Prerequisites

  • Read access to the requested assets

Request

POST https://{controlplane_path}/api/1/rest/public/platform_mcp/mcp/pygen
      

Path parameters

Key Description
controlplane_path Required. The path to the SnapLogic control plane: elastic.snaplogic.com
For the UAT or EMEA control plane, substitute the name for elastic. For example:
  • uat.elastic.snaplogic.com
  • emea.snaplogic.com

Request headers

Key Type Description
Authorization String Required. SLToken or HTTP Basic credentials. Forwarded verbatim to the Platform MCP Server for per-request authentication.
Content-Type String Required. Must be application/json.
Mcp-Session-Id String Optional. Session identifier returned by the initialize response. Required for all requests after the initial initialize call. Omit on the first request.

Request body

A JSON-RPC 2.0 request object:

Key Type Description
jsonrpc String Required. Must be "2.0".
id Integer or String Required. for requests; omit for notifications. A unique identifier used to correlate the response. Must be omitted when method is notifications/initialized.
method String Required. The MCP method to invoke. Supported values:
  • initialize — Start a new MCP session and negotiate capabilities.
  • notifications/initialized — Confirm the handshake is complete. This is a JSON-RPC notification; omit the id field.
  • tools/list — List available PyGen tools.
  • tools/call — Invoke a specific PyGen tool.
params Object Optional. Parameters for the method. For tools/call, provide name (the tool name) and arguments (tool-specific inputs). Use tools/list to discover the tools available in the current session. See Examples.

Response headers

Key Type Description
Mcp-Session-Id String Returned on a successful initialize response. Include this value in the Mcp-Session-Id request header for all subsequent requests in the session.

Response body

Responses are delivered as Server-Sent Events (SSE). Each event carries a JSON-RPC 2.0 response object in the data field:

event: message
data: {"jsonrpc": "2.0", "id": 1, "result": { ... }}

HTTP status codes:

Key Description
200 OK The request was forwarded and the SSE stream contains the response.
401 Unauthorized The request is missing a valid Authorization header.
502 Bad Gateway The Platform MCP Server is unreachable.
504 Gateway Timeout The Platform MCP Server did not respond within the timeout period.

Examples

Step 1: Initialize a session

POST https://cdn.elastic.snaplogic.com/api/1/rest/public/platform_mcp/mcp/pygen
Authorization: SLToken <your_token>
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-03-26",
    "capabilities": {},
    "clientInfo": { "name": "my-client", "version": "1.0" }
  }
}

The server responds with its capabilities and returns the Mcp-Session-Id in the response header. Use this session ID in all subsequent requests.

Step 2: Confirm the handshake

POST https://cdn.elastic.snaplogic.com/api/1/rest/public/platform_mcp/mcp/pygen
Authorization: SLToken <your_token>
Content-Type: application/json
Mcp-Session-Id: <session_id>

{
  "jsonrpc": "2.0",
  "method": "notifications/initialized"
}

This is a JSON-RPC notification — omit the id field. The server does not send a response. The session is now fully initialized.

Step 3: List available tools

POST https://cdn.elastic.snaplogic.com/api/1/rest/public/platform_mcp/mcp/pygen
Authorization: SLToken <your_token>
Content-Type: application/json
Mcp-Session-Id: <session_id>

{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list",
  "params": {}
}

Step 4: Call a PyGen tool

POST https://cdn.elastic.snaplogic.com/api/1/rest/public/platform_mcp/mcp/pygen
Authorization: SLToken <your_token>
Content-Type: application/json
Mcp-Session-Id: <session_id>

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "pygen_get_snap_documentation",
    "arguments": {
      "snap_names": ["Mapper", "JSON Formatter", "REST Get"]
    }
  }
}