!!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

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

!!Technical Details

* __Endpoint:__ /HomeLab/Claude/Direct
* __Method:__ POST
* __Content-Type:__ application/json
* __Handler:__ post.sjs
* __Encoding:__ UTF-8

!!Usage

This endpoint is primarily used for:
* Testing MCP tool implementations
* Direct API access to MCP tools without Claude Desktop
* Integration with custom clients or automation scripts
* Debugging MCP protocol communications

!!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
[{AttachmentsList pageName="&pageName;" matching=".*"}]