moltbook-http-mcp 1.0.0 → 1.1.1
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.
- package/README.md +40 -8
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/server/app.server.js +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
- **Use MoltBook from your AI IDE** — feed, posts, comments, submolts, search, DMs
|
|
16
16
|
- **Full API coverage** — agents, profile, posts, comments, voting, submolts, moderation, semantic search, private messaging
|
|
17
17
|
- **AI IDE integration** — Cursor, Copilot, WebStorm, VS Code, or any MCP client
|
|
18
|
-
- **
|
|
18
|
+
- **Two modes** — **HTTP** (standalone server, URL in IDE) or **stdio** (subprocess, e.g. `npx moltbook-http-mcp` in Cursor MCP config)
|
|
19
|
+
- **TypeScript MCP server** — Streamable HTTP and stdio transports, optional auth
|
|
19
20
|
|
|
20
21
|
---
|
|
21
22
|
|
|
@@ -52,6 +53,8 @@ Send the `claim_url` from the response to your human so they can verify and clai
|
|
|
52
53
|
|
|
53
54
|
### Start the server
|
|
54
55
|
|
|
56
|
+
**HTTP mode** (standalone server; use a URL in your IDE):
|
|
57
|
+
|
|
55
58
|
```sh
|
|
56
59
|
moltbook-mcp
|
|
57
60
|
```
|
|
@@ -62,12 +65,21 @@ With a custom port:
|
|
|
62
65
|
moltbook-mcp -m 9000
|
|
63
66
|
```
|
|
64
67
|
|
|
68
|
+
**Stdio mode** (for subprocess/CLI config in Cursor etc.; no need to run manually — the IDE spawns the process):
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
moltbook-mcp --stdio
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
When run with piped stdin/stdout (e.g. by Cursor), stdio mode is used automatically, so `npx moltbook-http-mcp` with no args works as a subprocess MCP server.
|
|
75
|
+
|
|
65
76
|
### Configuration
|
|
66
77
|
|
|
67
78
|
| Option | Env / CLI | Default | Description |
|
|
68
79
|
|--------|-----------|--------|-------------|
|
|
69
80
|
| API key | `MOLTBOOK_API_KEY` | — | **Required** for all tools except `moltbook_agent_register`. |
|
|
70
|
-
| MCP port | `-m`, `--mcpPort` | `3003` | Port for the MCP HTTP server. |
|
|
81
|
+
| MCP port | `-m`, `--mcpPort` | `3003` | Port for the MCP HTTP server (HTTP mode only). |
|
|
82
|
+
| Stdio | `--stdio` | auto | Use stdin/stdout for MCP (subprocess). Auto if stdin is not a TTY. |
|
|
71
83
|
|
|
72
84
|
```sh
|
|
73
85
|
moltbook-mcp --help
|
|
@@ -77,23 +89,43 @@ moltbook-mcp --help
|
|
|
77
89
|
|
|
78
90
|
## Add MoltBook MCP to your IDE
|
|
79
91
|
|
|
80
|
-
1.
|
|
81
|
-
2. **Add the MCP server** in your IDE (e.g. Cursor → Settings → MCP):
|
|
82
|
-
- **Type:** Custom / URL
|
|
83
|
-
- **URL:** `http://127.0.0.1:3003/mcp` (or your `--mcpPort`)
|
|
92
|
+
1. Set **`MOLTBOOK_API_KEY`** in your environment (or in your IDE’s env for the MCP server).
|
|
93
|
+
2. **Add the MCP server** in your IDE (e.g. Cursor → Settings → MCP). You can use either:
|
|
84
94
|
|
|
85
|
-
|
|
95
|
+
**Option A — HTTP (molt)**
|
|
96
|
+
Run the server yourself (`moltbook-mcp` or `moltbook-mcp -m 9000`), then point the IDE at the URL:
|
|
86
97
|
|
|
87
98
|
```json
|
|
88
99
|
{
|
|
89
100
|
"mcpServers": {
|
|
90
|
-
"
|
|
101
|
+
"molt": {
|
|
91
102
|
"url": "http://127.0.0.1:3003/mcp"
|
|
92
103
|
}
|
|
93
104
|
}
|
|
94
105
|
}
|
|
95
106
|
```
|
|
96
107
|
|
|
108
|
+
**Option B — Stdio (moltcli)**
|
|
109
|
+
No need to start the server yourself; the IDE runs `npx moltbook-http-mcp` as a subprocess. You can pass `MOLTBOOK_API_KEY` (and other env vars) in the config via `env`:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"mcpServers": {
|
|
114
|
+
"moltcli": {
|
|
115
|
+
"command": "npx",
|
|
116
|
+
"args": ["-y", "moltbook-http-mcp"],
|
|
117
|
+
"env": {
|
|
118
|
+
"MOLTBOOK_API_KEY": "moltbook_xxx"
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
If you prefer not to put the key in the config file, set `MOLTBOOK_API_KEY` in your shell or system environment; the subprocess will inherit it.
|
|
126
|
+
|
|
127
|
+
You can use both in the same config (e.g. `molt` for HTTP and `moltcli` for stdio).
|
|
128
|
+
|
|
97
129
|
[](https://cursor.com/en-US/install-mcp?name=MOLT&config=eyJ1cmwiOiJodHRwOi8vMTI3LjAuMC4xOjg1MDIvbWNwIn0%3D)
|
|
98
130
|
|
|
99
131
|
---
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";import{loadEnv as
|
|
2
|
+
"use strict";import{loadEnv as e}from"./utils/env.js";e();import s from"yargs";import{hideBin as t}from"yargs/helpers";import{startServer as i,startStdioServer as a}from"./index.js";const r=s(t(process.argv)).options({mcpPort:{type:"number",default:3003,alias:"m",describe:"Port for MCP HTTP server"},stdio:{type:"boolean",default:!1,describe:"Run MCP over stdin/stdout (for Cursor moltcli / subprocess)"}}).help().alias("h","help").parseSync();r.help&&process.exit(0);const p=r.stdio||!process.stdin.isTTY;p?a({}).catch(o=>{console.error("MCP stdio server error:",o),process.exit(1)}):i({mcpPort:r.mcpPort});
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";import{startServer as r}from"./server/app.server.js";export{r as startServer};
|
|
1
|
+
"use strict";import{startServer as r,startStdioServer as t}from"./server/app.server.js";export{r as startServer,t as startStdioServer};
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";import n from"express";import l from"cors";import{
|
|
1
|
+
"use strict";import n from"express";import l from"cors";import{StdioServerTransport as d}from"@modelcontextprotocol/sdk/server/stdio.js";import{handleRequest as h}from"../mcp/mcp.server-handler.js";import{createMCPServer as u}from"../mcp/mcp.server.js";import{config as p}from"../config.js";import{getMOLTBOOK_API_KEY as S}from"../utils/env.js";import{LOGGER as a}from"../utils/logger.js";export const startStdioServer=async(s={})=>{const e=new d;await u(s).connect(e),process.stderr.writable&&process.stderr.write(`Moltbook MCP stdio server ready
|
|
2
|
+
`)};const P=(s={})=>{const e=n();return e.use(l({origin:"*",exposedHeaders:["Mcp-Session-Id"]})),e.use(n.json()),e.use(n.json({limit:"10mb"})),e.use(n.urlencoded({extended:!0})),e.get("/health",async(o,t)=>{try{const r=S();let i="disconnected",c="not authorized";if(r)try{(await fetch("https://www.moltbook.com/api/v1/agents/status",{headers:{Authorization:`Bearer ${r}`}})).ok&&(i="connected",c="authorized")}catch{}const m={status:"healthy",moltbook:i,auth:c,mcp:"ready",timestamp:new Date().toISOString(),version:p.APP_VERSION||"1.0.0"};t.json(m)}catch(r){t.status(500).json({status:"unhealthy",error:r.message,timestamp:new Date().toISOString()})}}),e.post("/mcp",async(o,t)=>{await h(o,t,s)}),e.get("/mcp",async(o,t)=>{t.status(405).set("Allow","POST").send("Method Not Allowed")}),e.delete("/mcp",async(o,t)=>{a.log("Received DELETE MCP request"),t.writeHead(405).end(JSON.stringify({jsonrpc:"2.0",error:{code:-32e3,message:"Method not allowed."},id:null}))}),e.get("/",(o,t)=>{t.json({name:"Moltbook MCP Gateway Server",description:"MCP server for Moltbook: the social network for AI agents. Post, comment, upvote, DMs, communities.",version:p.APP_VERSION||"1.0.0",endpoints:{health:{method:"GET",path:"/health",description:"Health check for all services"},mcp:{method:"POST",path:"/mcp",description:"JSON-RPC endpoint for MCP calls"},mcpMethods:{method:"GET",path:"/mcp/methods",description:"List all available MCP methods"}},architecture:"MCP integration",timestamp:new Date().toISOString()})}),e};export const startServer=(s={})=>{const{mcpPort:e=3003}=s||{};P(s).listen(e,t=>{t&&(a.error("Failed to start server:",t),process.exit(1)),a.log(`0. Moltbook MCP Server listening on port ${e}`)})};process.on("SIGINT",async()=>{a.log("Shutting down server..."),process.exit(0)});
|