@blockrun/mcp 0.4.2 → 0.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * BlockRun MCP Server — HTTP Transport
4
+ *
5
+ * Runs as an HTTP server for:
6
+ * - Claude.ai connectors (claudeai-proxy)
7
+ * - Claude Code Remote (CCR) cloud sessions
8
+ * - Web-based agents
9
+ * - Any MCP client supporting HTTP transport
10
+ *
11
+ * Usage:
12
+ * npx @blockrun/mcp --http # Start HTTP server on port 3402
13
+ * npx @blockrun/mcp --http --port 8080 # Custom port
14
+ *
15
+ * The server implements the MCP Streamable HTTP transport specification,
16
+ * supporting both SSE streaming and direct HTTP responses.
17
+ */
18
+ declare function startHttpServer(port?: number): Promise<void>;
19
+
20
+ export { startHttpServer };
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ initializeMcpServer
4
+ } from "./chunk-H2DXT5AJ.js";
5
+
6
+ // src/http-server.ts
7
+ import { createServer } from "http";
8
+ import { randomUUID } from "crypto";
9
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
10
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
11
+ var DEFAULT_PORT = 3402;
12
+ async function startHttpServer(port = DEFAULT_PORT) {
13
+ const server = new McpServer({
14
+ name: "blockrun-mcp",
15
+ version: "0.5.1"
16
+ });
17
+ initializeMcpServer(server);
18
+ const transport = new StreamableHTTPServerTransport({
19
+ sessionIdGenerator: () => randomUUID()
20
+ });
21
+ await server.connect(transport);
22
+ const httpServer = createServer((req, res) => {
23
+ res.setHeader("Access-Control-Allow-Origin", "*");
24
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, DELETE, OPTIONS");
25
+ res.setHeader("Access-Control-Allow-Headers", "Content-Type, mcp-session-id, Authorization");
26
+ res.setHeader("Access-Control-Expose-Headers", "mcp-session-id");
27
+ if (req.method === "OPTIONS") {
28
+ res.writeHead(204);
29
+ res.end();
30
+ return;
31
+ }
32
+ if (req.method === "GET" && req.url === "/health") {
33
+ res.writeHead(200, { "Content-Type": "application/json" });
34
+ res.end(JSON.stringify({ status: "ok", server: "blockrun-mcp", version: "0.5.1", transport: "http" }));
35
+ return;
36
+ }
37
+ if (req.url === "/mcp" || req.url === "/") {
38
+ transport.handleRequest(req, res);
39
+ return;
40
+ }
41
+ res.writeHead(404);
42
+ res.end("Not found");
43
+ });
44
+ httpServer.listen(port, () => {
45
+ console.error(`BlockRun MCP Server (HTTP) listening on http://localhost:${port}`);
46
+ console.error(`MCP endpoint: http://localhost:${port}/mcp`);
47
+ console.error(`Health check: http://localhost:${port}/health`);
48
+ });
49
+ const shutdown = () => {
50
+ console.error("Shutting down...");
51
+ httpServer.close();
52
+ process.exit(0);
53
+ };
54
+ process.on("SIGINT", shutdown);
55
+ process.on("SIGTERM", shutdown);
56
+ }
57
+ export {
58
+ startHttpServer
59
+ };