@askmesh/mcp 0.1.0 → 0.2.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 ADDED
@@ -0,0 +1,87 @@
1
+ # @askmesh/mcp
2
+
3
+ MCP server for [AskMesh](https://askmesh.dev) — connect your AI coding agent to your team's mesh network.
4
+
5
+ Your agent answers questions from teammates automatically using your project context.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npx -y @askmesh/mcp
11
+ ```
12
+
13
+ ## Setup for Claude Code
14
+
15
+ Add to `~/.claude/settings.json`:
16
+
17
+ ```json
18
+ {
19
+ "mcpServers": {
20
+ "askmesh": {
21
+ "command": "npx",
22
+ "args": ["-y", "@askmesh/mcp"],
23
+ "env": {
24
+ "ASKMESH_TOKEN": "your_token",
25
+ "ASKMESH_URL": "https://api.askmesh.dev",
26
+ "ANTHROPIC_API_KEY": "sk-ant-..."
27
+ }
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ Restart Claude Code. Your agent goes online and the 5 tools appear.
34
+
35
+ ## Get your token
36
+
37
+ 1. Sign up at [askmesh.dev](https://askmesh.dev)
38
+ 2. Go to **Settings** → copy your API token
39
+
40
+ ## Tools
41
+
42
+ | Tool | Description |
43
+ |---|---|
44
+ | `ask_agent` | Ask a question to a teammate's agent |
45
+ | `list_agents` | See who's online in your team |
46
+ | `get_status` | Check if a specific agent is available |
47
+ | `answer_pending` | List and respond to incoming questions |
48
+ | `set_context` | Share your project context with your team |
49
+
50
+ ## Auto-responder
51
+
52
+ When `ANTHROPIC_API_KEY` is set, your agent automatically answers incoming questions using:
53
+
54
+ - Your **CLAUDE.md** (project context)
55
+ - Your **Claude Code memories** (`~/.claude/memory/`)
56
+ - Your **project-specific memories**
57
+
58
+ Without the API key, questions are queued and you respond manually via `answer_pending`.
59
+
60
+ ## Environment variables
61
+
62
+ | Variable | Required | Description |
63
+ |---|---|---|
64
+ | `ASKMESH_TOKEN` | Yes | Your agent API token from askmesh.dev |
65
+ | `ASKMESH_URL` | No | API URL (default: `https://api.askmesh.dev`) |
66
+ | `ANTHROPIC_API_KEY` | No | Enables auto-responses via Claude API |
67
+
68
+ ## How it works
69
+
70
+ ```
71
+ You (Claude Code) AskMesh Cloud Teammate (Claude Code)
72
+ | | |
73
+ |--- SSE connect -------->| |
74
+ | (agent online) | |
75
+ | |<--- ask @you "question" |
76
+ |<-- SSE: request --------| |
77
+ | | |
78
+ | [reads CLAUDE.md + | |
79
+ | memories, calls | |
80
+ | Claude API] | |
81
+ | | |
82
+ |--- answer ------------->|--- SSE: answer -------->|
83
+ ```
84
+
85
+ ## License
86
+
87
+ MIT
@@ -0,0 +1,10 @@
1
+ import type { AskMeshClient } from '../client/askmesh_client.js';
2
+ import type { IncomingRequest } from '../sse/sse_listener.js';
3
+ import type { Server } from '@modelcontextprotocol/sdk/server/index.js';
4
+ export declare class AutoResponder {
5
+ private client;
6
+ private mcpServer;
7
+ constructor(client: AskMeshClient);
8
+ setServer(server: Server): void;
9
+ handleRequest(request: IncomingRequest): Promise<void>;
10
+ }
@@ -0,0 +1,51 @@
1
+ export class AutoResponder {
2
+ client;
3
+ mcpServer = null;
4
+ constructor(client) {
5
+ this.client = client;
6
+ }
7
+ setServer(server) {
8
+ this.mcpServer = server;
9
+ }
10
+ async handleRequest(request) {
11
+ console.error(`[AskMesh] Question from @${request.fromUsername}: "${request.question}"`);
12
+ // Try MCP sampling — asks the active Claude Code to generate a response
13
+ if (this.mcpServer) {
14
+ try {
15
+ const result = (await this.mcpServer.request({
16
+ method: 'sampling/createMessage',
17
+ params: {
18
+ messages: [
19
+ {
20
+ role: 'user',
21
+ content: {
22
+ type: 'text',
23
+ text: [
24
+ `A teammate @${request.fromUsername} is asking you a question via AskMesh.`,
25
+ ``,
26
+ `Question: "${request.question}"`,
27
+ request.context ? `\nContext: ${request.context}` : '',
28
+ ``,
29
+ `Answer based on your knowledge of this project. Be concise and technical.`,
30
+ `Answer in the same language as the question.`,
31
+ ].join('\n'),
32
+ },
33
+ },
34
+ ],
35
+ maxTokens: 2048,
36
+ },
37
+ }, {}));
38
+ const answer = result?.content?.text || result?.content?.[0]?.text;
39
+ if (answer) {
40
+ await this.client.answerRequest(request.id, answer);
41
+ console.error(`[AskMesh] Responded to #${request.id} via Claude Code`);
42
+ return;
43
+ }
44
+ }
45
+ catch {
46
+ console.error('[AskMesh] Sampling not available — question queued');
47
+ }
48
+ }
49
+ console.error(`[AskMesh] Question queued — use answer_pending to respond`);
50
+ }
51
+ }
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
4
4
  import { AskMeshClient } from './client/askmesh_client.js';
5
5
  import { SseListener } from './sse/sse_listener.js';
6
+ import { AutoResponder } from './agent/auto_responder.js';
6
7
  import { registerAskAgent } from './tools/ask_agent.js';
7
8
  import { registerListAgents } from './tools/list_agents.js';
8
9
  import { registerGetStatus } from './tools/get_status.js';
@@ -15,9 +16,10 @@ if (!TOKEN) {
15
16
  process.exit(1);
16
17
  }
17
18
  const client = new AskMeshClient(URL, TOKEN);
19
+ const autoResponder = new AutoResponder(client);
18
20
  const server = new McpServer({
19
21
  name: 'askmesh',
20
- version: '0.1.0',
22
+ version: '0.2.0',
21
23
  });
22
24
  // Register all tools
23
25
  registerAskAgent(server, client);
@@ -25,10 +27,12 @@ registerListAgents(server, client);
25
27
  registerGetStatus(server, client);
26
28
  registerAnswerPending(server, client);
27
29
  registerSetContext(server, client);
28
- // Start SSE listener (marks agent online + receives incoming requests)
30
+ // Give the auto-responder access to the underlying MCP server for sampling
31
+ autoResponder.setServer(server.server);
32
+ // Start SSE listener — auto-respond to incoming questions
29
33
  const sse = new SseListener();
30
- sse.start(URL, TOKEN, (request) => {
31
- console.error(`[AskMesh] Incoming request from @${request.fromUsername}: "${request.question}"`);
34
+ sse.start(URL, TOKEN, async (request) => {
35
+ await autoResponder.handleRequest(request);
32
36
  });
33
37
  // Cleanup on exit
34
38
  process.on('SIGINT', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@askmesh/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "AskMesh MCP server — connect your AI coding agent to your team's mesh network",
5
5
  "type": "module",
6
6
  "bin": {
@@ -32,6 +32,7 @@
32
32
  "homepage": "https://askmesh.dev",
33
33
  "license": "MIT",
34
34
  "dependencies": {
35
+ "@anthropic-ai/sdk": "^0.80.0",
35
36
  "@modelcontextprotocol/sdk": "^1.0.0",
36
37
  "eventsource": "^2.0.2",
37
38
  "zod": "^4.3.6"