MCP Direct API Endpoint

This page provides a direct HTTP POST endpoint for interacting with the Claude MCP (Model Context Protocol) server.

Purpose

The Direct endpoint serves as a lightweight API gateway that allows external clients to send MCP requests directly to the OpenForum-based MCP server without going through the standard Claude Desktop client.

How It Works

  1. The endpoint accepts HTTP POST requests at `/HomeLab/Claude/Direct`
  2. Request body should contain JSON-formatted MCP protocol messages
  3. The `post.sjs` script reads the incoming JSON data from the request stream
  4. Data is passed to the main Claude.sjs handler via `Claude.handleRequest()`
  5. The response is returned as JSON to the client

Technical Details

Usage

This endpoint is primarily used for:

Code

The implementation is simple and straightforward: var jsonData = ""; var reader = new java.io.BufferedReader( new java.io.InputStreamReader( transaction.getConnection().getInputStream(), java.nio.charset.StandardCharsets.UTF_8 ) ); while ((line = reader.readLine()) != null) { jsonData = "" line; } var data = Claude.handleRequest( jsonData ); transaction.sendJSON( JSON.stringify(data) );

Attachments