From 72998cc234a680aadb8bc4e037e313ee39728d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=95=D0=B2=D0=B3=D0=B5=D0=BD=D0=B8=D1=8F?= Date: Tue, 30 Jun 2026 15:44:21 +0400 Subject: [PATCH] Add stdio transport entry point (src/stdio.js) Adds a stdio entry point that reuses the existing createApiClient + registerTools from src/index.js and connects a StdioServerTransport. The HTTP server (src/index.js) is unchanged. Enables local use in MCP clients (Claude Desktop, Cursor) and wrapping by mcp-proxy (Glama). --- package.json | 4 +++- src/stdio.js | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 src/stdio.js diff --git a/package.json b/package.json index efac341..ff229ca 100644 --- a/package.json +++ b/package.json @@ -4,10 +4,12 @@ "description": "Official MCP server for Publora - control social media scheduling from AI assistants", "main": "src/index.js", "bin": { - "publora-mcp": "src/index.js" + "publora-mcp": "src/index.js", + "publora-mcp-stdio": "src/stdio.js" }, "scripts": { "start": "node src/index.js", + "start:stdio": "node src/stdio.js", "test": "node --test src/index.test.js" }, "keywords": [ diff --git a/src/stdio.js b/src/stdio.js new file mode 100644 index 0000000..a46cf21 --- /dev/null +++ b/src/stdio.js @@ -0,0 +1,37 @@ +#!/usr/bin/env node + +/** + * Publora MCP server — stdio entry point. + * + * Runs the same tools as the HTTP server (src/index.js), but over the stdio + * transport so the server can be launched locally by MCP clients (Claude + * Desktop, Cursor, etc.) and by tooling that wraps stdio servers. + * + * The HTTP server in src/index.js is untouched; this file only reuses its + * createApiClient + registerTools and connects a StdioServerTransport. + * + * API key is read from the PUBLORA_API_KEY env var. Listing tools + * (introspection) works without a key; a key is only needed to call tools. + */ + +const { McpServer } = require("@modelcontextprotocol/sdk/server/mcp.js"); +const { StdioServerTransport } = require("@modelcontextprotocol/sdk/server/stdio.js"); +const { createApiClient, registerTools } = require("./index.js"); + +async function main() { + const apiKey = process.env.PUBLORA_API_KEY || ""; + + const mcpServer = new McpServer({ name: "publora", version: "1.0.0" }); + const apiRequest = createApiClient(apiKey); + registerTools(mcpServer, apiRequest); + + const transport = new StdioServerTransport(); + await mcpServer.connect(transport); + // Never write to stdout here — stdout is the JSON-RPC channel. + console.error("Publora MCP server running on stdio"); +} + +main().catch((err) => { + console.error("Failed to start Publora MCP stdio server:", err); + process.exit(1); +});