counsel-mcp-server 0.1.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Counsel AI
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,414 @@
1
+ # Counsel MCP Server
2
+
3
+ [![npm version](https://img.shields.io/npm/v/counsel-mcp-server.svg)](https://www.npmjs.com/package/counsel-mcp-server)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
+ [![Node.js Version](https://img.shields.io/node/v/counsel-mcp-server.svg)](https://nodejs.org)
6
+
7
+ An open-source [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that connects AI agents to the [Counsel](https://counsel.getmason.dev) API for strategic reasoning and multi-perspective analysis.
8
+
9
+ ## Features
10
+
11
+ - **Strategic Reasoning** - Access Counsel's debate and multi-perspective reasoning engines
12
+ - **Advisor Sessions** - Run interactive intake and profile tuning sessions
13
+ - **Native OAuth 2.0** - Standard MCP authentication handled automatically by clients
14
+ - **HTTP Transport** - Works with any MCP client supporting HTTP/SSE transport
15
+
16
+ ---
17
+
18
+ ## Table of Contents
19
+
20
+ - [Installation](#installation)
21
+ - [Claude Desktop](#claude-desktop)
22
+ - [Claude Code (CLI)](#claude-code-cli)
23
+ - [Cursor](#cursor)
24
+ - [Windsurf](#windsurf)
25
+ - [VS Code with Copilot](#vs-code-with-copilot)
26
+ - [Other MCP Clients](#other-mcp-clients)
27
+ - [Authentication](#authentication)
28
+ - [Available Tools](#available-tools)
29
+ - [Usage Examples](#usage-examples)
30
+ - [Configuration](#configuration)
31
+ - [Troubleshooting](#troubleshooting)
32
+ - [Development](#development)
33
+ - [Contributing](#contributing)
34
+ - [License](#license)
35
+
36
+ ---
37
+
38
+ ## Installation
39
+
40
+ ### Prerequisites
41
+
42
+ 1. **Node.js 18+** installed on your system
43
+ 2. A **Counsel account** at [counsel.getmason.dev](https://counsel.getmason.dev)
44
+
45
+ ### Claude Desktop
46
+
47
+ Add to your `claude_desktop_config.json`:
48
+
49
+ <details>
50
+ <summary><b>macOS</b>: <code>~/Library/Application Support/Claude/claude_desktop_config.json</code></summary>
51
+
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "counsel": {
56
+ "command": "npx",
57
+ "args": ["-y", "counsel-mcp-server", "start"]
58
+ }
59
+ }
60
+ }
61
+ ```
62
+
63
+ </details>
64
+
65
+ <details>
66
+ <summary><b>Windows</b>: <code>%APPDATA%\Claude\claude_desktop_config.json</code></summary>
67
+
68
+ ```json
69
+ {
70
+ "mcpServers": {
71
+ "counsel": {
72
+ "command": "npx",
73
+ "args": ["-y", "counsel-mcp-server", "start"]
74
+ }
75
+ }
76
+ }
77
+ ```
78
+
79
+ </details>
80
+
81
+ ### Claude Code (CLI)
82
+
83
+ ```bash
84
+ claude mcp add counsel -- npx -y counsel-mcp-server start
85
+ ```
86
+
87
+ Or manually add to your MCP settings:
88
+
89
+ ```json
90
+ {
91
+ "mcpServers": {
92
+ "counsel": {
93
+ "command": "npx",
94
+ "args": ["-y", "counsel-mcp-server", "start"]
95
+ }
96
+ }
97
+ }
98
+ ```
99
+
100
+ ### Cursor
101
+
102
+ Add to your Cursor MCP configuration (`.cursor/mcp.json` in your project or global settings):
103
+
104
+ ```json
105
+ {
106
+ "mcpServers": {
107
+ "counsel": {
108
+ "command": "npx",
109
+ "args": ["-y", "counsel-mcp-server", "start"]
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ ### Windsurf
116
+
117
+ Add to your Windsurf MCP configuration:
118
+
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "counsel": {
123
+ "command": "npx",
124
+ "args": ["-y", "counsel-mcp-server", "start"]
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ ### VS Code with Copilot
131
+
132
+ Add to your VS Code settings (`settings.json`):
133
+
134
+ ```json
135
+ {
136
+ "mcp.servers": {
137
+ "counsel": {
138
+ "command": "npx",
139
+ "args": ["-y", "counsel-mcp-server", "start"]
140
+ }
141
+ }
142
+ }
143
+ ```
144
+
145
+ ### Other MCP Clients
146
+
147
+ For any MCP-compatible client, configure with:
148
+
149
+ - **Command**: `npx`
150
+ - **Args**: `["-y", "counsel-mcp-server", "start"]`
151
+ - **Transport**: `stdio` (default) or `http` at `http://localhost:3000/mcp`
152
+
153
+ #### HTTP Mode (Advanced)
154
+
155
+ If your client supports HTTP transport, you can run the server standalone:
156
+
157
+ ```bash
158
+ npx counsel-mcp-server start --port 3000
159
+ ```
160
+
161
+ Then configure your client with:
162
+ ```json
163
+ {
164
+ "mcpServers": {
165
+ "counsel": {
166
+ "url": "http://localhost:3000/mcp",
167
+ "transport": "http"
168
+ }
169
+ }
170
+ }
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Authentication
176
+
177
+ Authentication is handled automatically through OAuth 2.0:
178
+
179
+ 1. When you first use a Counsel tool, your MCP client will prompt for authentication
180
+ 2. You'll be redirected to sign in with your Counsel account
181
+ 3. After authorization, tokens are managed automatically
182
+
183
+ **No manual login required** - your MCP client handles the entire flow.
184
+
185
+ ### OAuth Endpoints
186
+
187
+ The server exposes standard OAuth 2.0 endpoints:
188
+
189
+ | Endpoint | Description |
190
+ |----------|-------------|
191
+ | `/.well-known/oauth-authorization-server` | OAuth metadata discovery |
192
+ | `/authorize` | Authorization endpoint |
193
+ | `/token` | Token exchange endpoint |
194
+ | `/register` | Dynamic client registration |
195
+
196
+ ---
197
+
198
+ ## Available Tools
199
+
200
+ ### `start_consultation`
201
+
202
+ Start a new strategic consultation (debate) to analyze a complex question with multiple perspectives.
203
+
204
+ | Parameter | Type | Required | Description |
205
+ |-----------|------|----------|-------------|
206
+ | `question` | string | Yes | The core question to analyze |
207
+ | `context` | string | No | Additional context about the situation |
208
+ | `mode` | enum | No | Depth of analysis: `quick`, `standard` (default), `deep` |
209
+ | `stakeholders` | string[] | No | Key stakeholders to consider |
210
+
211
+ **Example:**
212
+ ```
213
+ Start a consultation about "Should we migrate our monolith to microservices?"
214
+ with context about our 50-person engineering team and mode set to deep
215
+ ```
216
+
217
+ ### `get_consultation_status`
218
+
219
+ Check the status of an ongoing consultation.
220
+
221
+ | Parameter | Type | Required | Description |
222
+ |-----------|------|----------|-------------|
223
+ | `debate_id` | string | Yes | The ID of the consultation |
224
+
225
+ ### `get_consultation_report`
226
+
227
+ Retrieve the final synthesis report from a completed consultation.
228
+
229
+ | Parameter | Type | Required | Description |
230
+ |-----------|------|----------|-------------|
231
+ | `debate_id` | string | Yes | The ID of the consultation |
232
+
233
+ ### `list_consultations`
234
+
235
+ List your past consultations.
236
+
237
+ | Parameter | Type | Required | Description |
238
+ |-----------|------|----------|-------------|
239
+ | `limit` | number | No | Number of results (default: 10) |
240
+
241
+ ### `sharpen_question`
242
+
243
+ Refine and improve a strategic question before starting a consultation.
244
+
245
+ | Parameter | Type | Required | Description |
246
+ |-----------|------|----------|-------------|
247
+ | `question` | string | Yes | The question to refine |
248
+ | `context` | string | No | Additional context |
249
+
250
+ **Example:**
251
+ ```
252
+ Sharpen this question: "Is AI good for our company?"
253
+ ```
254
+
255
+ ### `consult_advisor`
256
+
257
+ Start an interactive advisor session for brainstorming or scoping problems.
258
+
259
+ | Parameter | Type | Required | Description |
260
+ |-----------|------|----------|-------------|
261
+ | `question` | string | Yes | The initial topic or question |
262
+
263
+ ---
264
+
265
+ ## Usage Examples
266
+
267
+ ### Strategic Decision Making
268
+
269
+ ```
270
+ Use Counsel to analyze: "Should we expand into the European market in 2025?"
271
+
272
+ Consider these stakeholders: CEO, CFO, Head of Sales, Legal
273
+ Use deep analysis mode
274
+ ```
275
+
276
+ ### Question Refinement
277
+
278
+ ```
279
+ Use the sharpen_question tool to improve this question:
280
+ "How do we fix our culture?"
281
+
282
+ Context: We're a 200-person startup experiencing rapid growth
283
+ ```
284
+
285
+ ### Checking Consultation Progress
286
+
287
+ ```
288
+ Check the status of consultation abc-123-def
289
+ ```
290
+
291
+ ---
292
+
293
+ ## Configuration
294
+
295
+ ### Environment Variables
296
+
297
+ | Variable | Default | Description |
298
+ |----------|---------|-------------|
299
+ | `COUNSEL_API_URL` | `https://counsel.getmason.dev` | Counsel API base URL |
300
+ | `PORT` | `3000` | Server port (HTTP mode) |
301
+
302
+ ### CLI Options
303
+
304
+ ```bash
305
+ counsel-mcp start [options]
306
+
307
+ Options:
308
+ -p, --port <port> Port to listen on (default: 3000)
309
+ -h, --host <host> Host to bind to (default: localhost)
310
+ ```
311
+
312
+ ---
313
+
314
+ ## Troubleshooting
315
+
316
+ ### "Tool not found" Error
317
+
318
+ Ensure the MCP server is properly configured in your client. Restart your client after adding the configuration.
319
+
320
+ ### Authentication Issues
321
+
322
+ 1. Check that you have a valid Counsel account
323
+ 2. Try removing and re-adding the MCP server configuration
324
+ 3. Clear your client's MCP cache if available
325
+
326
+ ### Connection Refused
327
+
328
+ If running in HTTP mode, ensure:
329
+ - The server is running (`npx counsel-mcp-server start`)
330
+ - The port isn't blocked by a firewall
331
+ - No other process is using the same port
332
+
333
+ ### Server Not Starting
334
+
335
+ ```bash
336
+ # Check Node.js version (requires 18+)
337
+ node --version
338
+
339
+ # Try running directly to see errors
340
+ npx counsel-mcp-server start
341
+ ```
342
+
343
+ ### Debug Mode
344
+
345
+ For verbose logging, check your MCP client's logs or run the server directly in a terminal to see output.
346
+
347
+ ---
348
+
349
+ ## Development
350
+
351
+ ### Prerequisites
352
+
353
+ - Node.js 18+
354
+ - npm 9+
355
+
356
+ ### Setup
357
+
358
+ ```bash
359
+ git clone https://github.com/getmason-io/counsel-mcp-server.git
360
+ cd counsel-mcp-server
361
+ npm install
362
+ npm run build
363
+ ```
364
+
365
+ ### Commands
366
+
367
+ ```bash
368
+ npm run build # Compile TypeScript
369
+ npm run dev # Watch mode
370
+ npm run start # Run server
371
+ npm test # Run tests
372
+ npm run lint # Type check
373
+ ```
374
+
375
+ ### Project Structure
376
+
377
+ ```
378
+ src/
379
+ ├── index.ts # HTTP server, OAuth proxy, MCP transport
380
+ ├── client.ts # API client with request-scoped auth
381
+ ├── config.ts # Environment configuration
382
+ └── tools/
383
+ ├── debates.ts # Consultation tools
384
+ └── advisor.ts # Advisor session tools
385
+ ```
386
+
387
+ ---
388
+
389
+ ## Contributing
390
+
391
+ We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
392
+
393
+ ### Quick Start
394
+
395
+ 1. Fork the repository
396
+ 2. Create a feature branch: `git checkout -b feature/your-feature`
397
+ 3. Make your changes and add tests
398
+ 4. Run `npm test` to ensure tests pass
399
+ 5. Submit a pull request
400
+
401
+ ---
402
+
403
+ ## License
404
+
405
+ MIT License - see [LICENSE](LICENSE) for details.
406
+
407
+ ---
408
+
409
+ ## Links
410
+
411
+ - [Counsel Platform](https://counsel.getmason.dev) - Strategic reasoning platform
412
+ - [MCP Specification](https://modelcontextprotocol.io) - Model Context Protocol documentation
413
+ - [GitHub Issues](https://github.com/getmason-io/counsel-mcp-server/issues) - Report bugs or request features
414
+ - [GitHub Discussions](https://github.com/getmason-io/counsel-mcp-server/discussions) - Ask questions
@@ -0,0 +1,13 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { AsyncLocalStorage } from 'async_hooks';
3
+ interface RequestContext {
4
+ token: string;
5
+ }
6
+ export declare const requestContext: AsyncLocalStorage<RequestContext>;
7
+ /**
8
+ * Pre-configured Axios client for Counsel API calls.
9
+ * Automatically uses the Bearer token from the current request context.
10
+ */
11
+ export declare const apiClient: AxiosInstance;
12
+ export {};
13
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,UAAU,cAAc;IACtB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,cAAc,mCAA0C,CAAC;AAStE;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,aAOtB,CAAC"}
package/dist/client.js ADDED
@@ -0,0 +1,34 @@
1
+ import axios from 'axios';
2
+ import { AsyncLocalStorage } from 'async_hooks';
3
+ import { config } from './config.js';
4
+ export const requestContext = new AsyncLocalStorage();
5
+ /**
6
+ * Get the current request's auth token from AsyncLocalStorage
7
+ */
8
+ function getCurrentToken() {
9
+ return requestContext.getStore()?.token;
10
+ }
11
+ /**
12
+ * Pre-configured Axios client for Counsel API calls.
13
+ * Automatically uses the Bearer token from the current request context.
14
+ */
15
+ export const apiClient = axios.create({
16
+ baseURL: config.COUNSEL_API_URL,
17
+ timeout: 60000,
18
+ headers: {
19
+ 'Content-Type': 'application/json',
20
+ 'User-Agent': 'counsel-mcp-server/0.1.0'
21
+ }
22
+ });
23
+ // Add request interceptor to inject the auth token from request context
24
+ apiClient.interceptors.request.use(async (reqConfig) => {
25
+ const token = getCurrentToken();
26
+ if (token) {
27
+ reqConfig.headers.Authorization = `Bearer ${token}`;
28
+ }
29
+ else {
30
+ console.warn("Auth Warning: No token in request context. API call may fail.");
31
+ }
32
+ return reqConfig;
33
+ });
34
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAwB,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAOrC,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,iBAAiB,EAAkB,CAAC;AAEtE;;GAEG;AACH,SAAS,eAAe;IACtB,OAAO,cAAc,CAAC,QAAQ,EAAE,EAAE,KAAK,CAAC;AAC1C,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAkB,KAAK,CAAC,MAAM,CAAC;IACnD,OAAO,EAAE,MAAM,CAAC,eAAe;IAC/B,OAAO,EAAE,KAAK;IACd,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;QAClC,YAAY,EAAE,0BAA0B;KACzC;CACF,CAAC,CAAC;AAEH,wEAAwE;AACxE,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;IACrD,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,IAAI,KAAK,EAAE,CAAC;QACV,SAAS,CAAC,OAAO,CAAC,aAAa,GAAG,UAAU,KAAK,EAAE,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAC;IAChF,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ export declare const config: {
2
+ COUNSEL_API_URL: string;
3
+ };
4
+ //# sourceMappingURL=config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,MAAM;;CAAkC,CAAC"}
package/dist/config.js ADDED
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ import dotenv from 'dotenv';
3
+ import path from 'path';
4
+ import { fileURLToPath } from 'url';
5
+ // Load .env from project root if it exists (mostly for dev)
6
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
+ dotenv.config({ path: path.resolve(__dirname, '../../.env') });
8
+ const ConfigSchema = z.object({
9
+ COUNSEL_API_URL: z.string().default('https://counsel.getmason.dev'),
10
+ });
11
+ export const config = ConfigSchema.parse(process.env);
12
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,4DAA4D;AAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AAC/D,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,CAAC,CAAC;AAE/D,MAAM,YAAY,GAAG,CAAC,CAAC,MAAM,CAAC;IAC5B,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,8BAA8B,CAAC;CACpE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,MAAM,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,137 @@
1
+ #!/usr/bin/env node
2
+ import express from "express";
3
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
4
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
5
+ import { ProxyOAuthServerProvider } from "@modelcontextprotocol/sdk/server/auth/providers/proxyProvider.js";
6
+ import { mcpAuthRouter } from "@modelcontextprotocol/sdk/server/auth/router.js";
7
+ import { requireBearerAuth } from "@modelcontextprotocol/sdk/server/auth/middleware/bearerAuth.js";
8
+ import { Command } from "commander";
9
+ import { randomUUID } from "crypto";
10
+ import { config } from "./config.js";
11
+ import { requestContext } from "./client.js";
12
+ import { TOOLS as DEBATE_TOOLS } from "./tools/debates.js";
13
+ import { TOOLS as ADVISOR_TOOLS } from "./tools/advisor.js";
14
+ const program = new Command();
15
+ program
16
+ .name("counsel-mcp")
17
+ .description("Counsel MCP Server - HTTP mode with OAuth")
18
+ .version("0.1.0");
19
+ program.command("start")
20
+ .description("Start the MCP server (HTTP mode)")
21
+ .option("-p, --port <port>", "Port to listen on", "3000")
22
+ .option("-h, --host <host>", "Host to bind to", "localhost")
23
+ .action(async (options) => {
24
+ const port = parseInt(options.port, 10);
25
+ const host = options.host;
26
+ const baseUrl = new URL(`http://${host}:${port}`);
27
+ // Use Counsel API as the upstream OAuth server
28
+ const counselApiUrl = config.COUNSEL_API_URL;
29
+ // Create OAuth provider that proxies to Counsel API
30
+ const oauthProvider = new ProxyOAuthServerProvider({
31
+ endpoints: {
32
+ authorizationUrl: `${counselApiUrl}/oauth/authorize`,
33
+ tokenUrl: `${counselApiUrl}/oauth/token`,
34
+ registrationUrl: `${counselApiUrl}/oauth/register`,
35
+ revocationUrl: `${counselApiUrl}/oauth/revoke`,
36
+ },
37
+ // Verify access tokens by calling Counsel API
38
+ verifyAccessToken: async (token) => {
39
+ // For now, we trust the token and extract info from it
40
+ // In production, you might want to call an introspection endpoint
41
+ // or validate the token format
42
+ return {
43
+ token,
44
+ clientId: "counsel-mcp-client",
45
+ scopes: ["counsel:read", "counsel:write"],
46
+ expiresAt: Math.floor(Date.now() / 1000) + 3600, // 1 hour from now
47
+ };
48
+ },
49
+ // Get client info - for proxy mode, we delegate to upstream
50
+ getClient: async (clientId) => {
51
+ // Return minimal client info - actual validation happens at Counsel API
52
+ return {
53
+ client_id: clientId,
54
+ redirect_uris: [],
55
+ grant_types: ["authorization_code", "refresh_token"],
56
+ response_types: ["code"],
57
+ token_endpoint_auth_method: "client_secret_post",
58
+ };
59
+ },
60
+ });
61
+ // Create Express app
62
+ const app = express();
63
+ app.use(express.json());
64
+ // Mount OAuth routes at root (handles /authorize, /token, /register, /.well-known/*)
65
+ app.use(mcpAuthRouter({
66
+ provider: oauthProvider,
67
+ issuerUrl: baseUrl,
68
+ baseUrl: baseUrl,
69
+ scopesSupported: ["counsel:read", "counsel:write"],
70
+ serviceDocumentationUrl: new URL("https://counsel.getmason.dev/docs"),
71
+ }));
72
+ // Create MCP server
73
+ const mcpServer = new McpServer({
74
+ name: "counsel-mcp",
75
+ version: "0.1.0",
76
+ });
77
+ // Register all tools
78
+ for (const tool of Object.values(DEBATE_TOOLS)) {
79
+ mcpServer.tool(tool.name, tool.schema, tool.handler);
80
+ }
81
+ for (const tool of Object.values(ADVISOR_TOOLS)) {
82
+ mcpServer.tool(tool.name, tool.schema, tool.handler);
83
+ }
84
+ // Create transport for each session
85
+ const transports = new Map();
86
+ // Protected MCP endpoint with Bearer auth
87
+ const mcpHandler = express.Router();
88
+ mcpHandler.use(requireBearerAuth({
89
+ verifier: oauthProvider,
90
+ requiredScopes: ["counsel:read"],
91
+ }));
92
+ // Handle MCP requests
93
+ mcpHandler.all("/", async (req, res) => {
94
+ // Get the auth token from the request (set by requireBearerAuth middleware)
95
+ const authInfo = req.auth;
96
+ const token = authInfo?.token;
97
+ // Run the request within the auth context so tools can access the token
98
+ await requestContext.run({ token }, async () => {
99
+ // Get or create session
100
+ const sessionId = req.headers["mcp-session-id"] || randomUUID();
101
+ let transport = transports.get(sessionId);
102
+ if (!transport) {
103
+ transport = new StreamableHTTPServerTransport({
104
+ sessionIdGenerator: () => sessionId,
105
+ });
106
+ transports.set(sessionId, transport);
107
+ // Connect transport to MCP server
108
+ await mcpServer.connect(transport);
109
+ // Clean up on close
110
+ transport.onclose = () => {
111
+ transports.delete(sessionId);
112
+ };
113
+ }
114
+ // Handle the request
115
+ await transport.handleRequest(req, res);
116
+ });
117
+ });
118
+ app.use("/mcp", mcpHandler);
119
+ // Health check endpoint
120
+ app.get("/health", (_req, res) => {
121
+ res.json({ status: "ok", version: "0.1.0" });
122
+ });
123
+ // Start server
124
+ app.listen(port, host, () => {
125
+ console.log(`Counsel MCP Server running at ${baseUrl.href}`);
126
+ console.log(`MCP endpoint: ${baseUrl.href}mcp`);
127
+ console.log(`OAuth authorize: ${baseUrl.href}authorize`);
128
+ console.log(`OAuth metadata: ${baseUrl.href}.well-known/oauth-authorization-server`);
129
+ console.log(`\nUpstream Counsel API: ${counselApiUrl}`);
130
+ });
131
+ });
132
+ // Default command is start
133
+ if (process.argv.length === 2) {
134
+ process.argv.push("start");
135
+ }
136
+ program.parse(process.argv);
137
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACnG,OAAO,EAAE,wBAAwB,EAAE,MAAM,kEAAkE,CAAC;AAC5G,OAAO,EAAE,aAAa,EAAE,MA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AEL,2BAA2B;AAC3B,IAAI,OAAO,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;IAC9B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC7B,CAAC;AAED,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { z } from "zod";
2
+ export declare const TOOLS: {
3
+ consult_advisor: {
4
+ name: string;
5
+ description: string;
6
+ schema: {
7
+ question: z.ZodString;
8
+ };
9
+ handler: (args: {
10
+ question: string;
11
+ }) => Promise<{
12
+ content: {
13
+ type: "text";
14
+ text: string;
15
+ }[];
16
+ }>;
17
+ };
18
+ };
19
+ //# sourceMappingURL=advisor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advisor.d.ts","sourceRoot":"","sources":["../../src/tools/advisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,KAAK;;;;;;;wBAOQ;YAAE,QAAQ,EAAE,MAAM,CAAA;SAAE;;;;;;;CAa7C,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { z } from "zod";
2
+ import { apiClient } from "../client.js";
3
+ export const TOOLS = {
4
+ consult_advisor: {
5
+ name: "consult_advisor",
6
+ description: "Start an interactive advisor session to brainstorm or scope a problem.",
7
+ schema: {
8
+ question: z.string().describe("The initial topic or question."),
9
+ },
10
+ handler: async (args) => {
11
+ const response = await apiClient.post("/advisor/start", { question: args.question });
12
+ return {
13
+ content: [{
14
+ type: "text",
15
+ text: `Advisor session started.\nSession ID: ${response.data.session_id}\n\nAdvisor: ${response.data.initial_message}`
16
+ }]
17
+ };
18
+ }
19
+ },
20
+ // Potential future tool: respond_to_advisor (for multi-turn via tool)
21
+ // For now, simple start is enough as per spec.
22
+ };
23
+ //# sourceMappingURL=advisor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"advisor.js","sourceRoot":"","sources":["../../src/tools/advisor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,eAAe,EAAE;QACf,IAAI,EAAE,iBAAiB;QACvB,WAAW,EAAE,wEAAwE;QACrF,MAAM,EAAE;YACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;SAChE;QACD,OAAO,EAAE,KAAK,EAAE,IAA0B,EAAE,EAAE;YAC5C,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;YACrF,OAAO;gBACL,OAAO,EAAE,CAAC;wBACR,IAAI,EAAE,MAAe;wBACrB,IAAI,EAAE,yCAAyC,QAAQ,CAAC,IAAI,CAAC,UAAU,gBAAgB,QAAQ,CAAC,IAAI,CAAC,eAAe,EAAE;qBACvH,CAAC;aACH,CAAC;QACJ,CAAC;KACF;IAED,sEAAsE;IACtE,+CAA+C;CAChD,CAAC"}
@@ -0,0 +1,87 @@
1
+ import { z } from "zod";
2
+ export declare const TOOLS: {
3
+ start_consultation: {
4
+ name: string;
5
+ description: string;
6
+ schema: {
7
+ question: z.ZodString;
8
+ context: z.ZodOptional<z.ZodString>;
9
+ mode: z.ZodDefault<z.ZodEnum<["quick", "standard", "deep"]>>;
10
+ stakeholders: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
11
+ };
12
+ handler: (args: {
13
+ question: string;
14
+ context?: string;
15
+ mode?: string;
16
+ stakeholders?: string[];
17
+ }) => Promise<{
18
+ content: {
19
+ type: "text";
20
+ text: string;
21
+ }[];
22
+ }>;
23
+ };
24
+ get_consultation_status: {
25
+ name: string;
26
+ description: string;
27
+ schema: {
28
+ debate_id: z.ZodString;
29
+ };
30
+ handler: (args: {
31
+ debate_id: string;
32
+ }) => Promise<{
33
+ content: {
34
+ type: "text";
35
+ text: string;
36
+ }[];
37
+ }>;
38
+ };
39
+ get_consultation_report: {
40
+ name: string;
41
+ description: string;
42
+ schema: {
43
+ debate_id: z.ZodString;
44
+ };
45
+ handler: (args: {
46
+ debate_id: string;
47
+ }) => Promise<{
48
+ content: {
49
+ type: "text";
50
+ text: any;
51
+ }[];
52
+ }>;
53
+ };
54
+ list_consultations: {
55
+ name: string;
56
+ description: string;
57
+ schema: {
58
+ limit: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
59
+ };
60
+ handler: (args: {
61
+ limit: number;
62
+ }) => Promise<{
63
+ content: {
64
+ type: "text";
65
+ text: any;
66
+ }[];
67
+ }>;
68
+ };
69
+ sharpen_question: {
70
+ name: string;
71
+ description: string;
72
+ schema: {
73
+ question: z.ZodString;
74
+ context: z.ZodOptional<z.ZodString>;
75
+ };
76
+ handler: (args: {
77
+ question: string;
78
+ context?: string;
79
+ }) => Promise<{
80
+ content: {
81
+ type: "text";
82
+ text: any;
83
+ }[];
84
+ }>;
85
+ };
86
+ };
87
+ //# sourceMappingURL=debates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debates.d.ts","sourceRoot":"","sources":["../../src/tools/debates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,KAAK;;;;;;;;;;wBAUQ;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;SAAE;;;;;;;;;;;;;wBAsB9E;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;wBAiBrB;YAAE,SAAS,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;wBA0BrB;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE;;;;;;;;;;;;;;wBAiBjB;YAAE,QAAQ,EAAE,MAAM,CAAC;YAAC,OAAO,CAAC,EAAE,MAAM,CAAA;SAAE;;;;;;;CAO/D,CAAC"}
@@ -0,0 +1,101 @@
1
+ import { z } from "zod";
2
+ import { apiClient } from "../client.js";
3
+ // Tool Definitions
4
+ export const TOOLS = {
5
+ start_consultation: {
6
+ name: "start_consultation",
7
+ description: "Start a new strategic consultation (debate) to analyze a complex question.",
8
+ schema: {
9
+ question: z.string().describe("The core question to verify or analyze."),
10
+ context: z.string().optional().describe("Additional context about the situation."),
11
+ mode: z.enum(["quick", "standard", "deep"]).default("standard").describe("Depth of analysis."),
12
+ stakeholders: z.array(z.string()).optional().describe("Key stakeholders to consider."),
13
+ },
14
+ handler: async (args) => {
15
+ const response = await apiClient.post("/debates", {
16
+ question: args.question,
17
+ context: args.context,
18
+ config: { mode: args.mode }, // Assuming API expects config object
19
+ stakeholders: args.stakeholders
20
+ });
21
+ return {
22
+ content: [{
23
+ type: "text",
24
+ text: `Consultation started successfully.\nID: ${response.data.id}\nStatus: ${response.data.status}`
25
+ }]
26
+ };
27
+ }
28
+ },
29
+ get_consultation_status: {
30
+ name: "get_consultation_status",
31
+ description: "Check the status of an ongoing consultation.",
32
+ schema: {
33
+ debate_id: z.string().describe("The ID of the consultation to check."),
34
+ },
35
+ handler: async (args) => {
36
+ const response = await apiClient.get(`/debates/${args.debate_id}`);
37
+ return {
38
+ content: [{
39
+ type: "text",
40
+ text: JSON.stringify(response.data, null, 2)
41
+ }]
42
+ };
43
+ }
44
+ },
45
+ get_consultation_report: {
46
+ name: "get_consultation_report",
47
+ description: "Retrieve the final synthesis report of a completed consultation.",
48
+ schema: {
49
+ debate_id: z.string().describe("The ID of the consultation."),
50
+ },
51
+ handler: async (args) => {
52
+ try {
53
+ const response = await apiClient.get(`/debates/${args.debate_id}/synthesis`);
54
+ return {
55
+ content: [{
56
+ type: "text",
57
+ text: response.data.markdown || response.data.content || JSON.stringify(response.data)
58
+ }]
59
+ };
60
+ }
61
+ catch (err) {
62
+ if (err.response?.status === 404) {
63
+ return {
64
+ content: [{ type: "text", text: "Report not ready or not found." }]
65
+ };
66
+ }
67
+ throw err;
68
+ }
69
+ }
70
+ },
71
+ list_consultations: {
72
+ name: "list_consultations",
73
+ description: "List past consultations.",
74
+ schema: {
75
+ limit: z.number().optional().default(10),
76
+ },
77
+ handler: async (args) => {
78
+ const response = await apiClient.get("/debates", { params: { limit: args.limit } });
79
+ const debates = response.data.items || response.data;
80
+ const summary = debates.map((d) => `- [${d.id}] ${d.question} (${d.status})`).join("\n");
81
+ return {
82
+ content: [{ type: "text", text: summary }]
83
+ };
84
+ }
85
+ },
86
+ sharpen_question: {
87
+ name: "sharpen_question",
88
+ description: "Refine a strategic question using the enhancement engine.",
89
+ schema: {
90
+ question: z.string(),
91
+ context: z.string().optional()
92
+ },
93
+ handler: async (args) => {
94
+ const response = await apiClient.post("/enhance/question", args);
95
+ return {
96
+ content: [{ type: "text", text: response.data.enhanced_question || response.data.result }]
97
+ };
98
+ }
99
+ }
100
+ };
101
+ //# sourceMappingURL=debates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debates.js","sourceRoot":"","sources":["../../src/tools/debates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,mBAAmB;AACnB,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,kBAAkB,EAAE;QAClB,IAAI,EAAE,oBAAoB;QAC1B,WAAW,EAAE,4EAA4E;QACzF,MAAM,EAAE;YACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;YACxE,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;YAClF,IAA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,CAAC,UAAU,EAAE,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;YACpF,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,QAAQ,CAAC,IAAI,CAAC;YACrD,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAM,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,QAAQ,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAC9F,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;aACpD,CAAC;QACJ,CAAC;KACF;IAED,gBAAgB,EAAE;QAChB,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,2DAA2D;QACxE,MAAM,EAAE;YACN,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;YACpB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;SAC/B;QACD,OAAO,EAAE,KAAK,EAAE,IAA4C,EAAE,EAAE;YAC9D,MAAM,QAAQ,GAAG,MAAM,SAAS,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;YACjE,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;aACpG,CAAC;QACJ,CAAC;KACF;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,77 @@
1
+ {
2
+ "name": "counsel-mcp-server",
3
+ "version": "0.1.0",
4
+ "description": "Open-source MCP server for connecting AI agents to the Counsel API",
5
+ "author": "Counsel AI",
6
+ "license": "MIT",
7
+ "type": "module",
8
+ "main": "dist/index.js",
9
+ "types": "dist/index.d.ts",
10
+ "bin": {
11
+ "counsel-mcp": "./dist/index.js"
12
+ },
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.js",
16
+ "types": "./dist/index.d.ts"
17
+ }
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "README.md",
22
+ "LICENSE"
23
+ ],
24
+ "engines": {
25
+ "node": ">=18.0.0"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc && chmod +x dist/index.js",
29
+ "start": "node dist/index.js start",
30
+ "dev": "tsc --watch",
31
+ "test": "vitest run",
32
+ "test:watch": "vitest",
33
+ "lint": "tsc --noEmit",
34
+ "prepublishOnly": "npm run build && npm run test"
35
+ },
36
+ "keywords": [
37
+ "mcp",
38
+ "model-context-protocol",
39
+ "counsel",
40
+ "ai",
41
+ "agent",
42
+ "llm",
43
+ "claude",
44
+ "openai",
45
+ "cursor",
46
+ "vscode",
47
+ "strategic-reasoning",
48
+ "debate"
49
+ ],
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/getmason-io/counsel-mcp-server.git"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/getmason-io/counsel-mcp-server/issues"
56
+ },
57
+ "homepage": "https://github.com/getmason-io/counsel-mcp-server#readme",
58
+ "publishConfig": {
59
+ "access": "public",
60
+ "registry": "https://registry.npmjs.org/"
61
+ },
62
+ "dependencies": {
63
+ "@hono/node-server": "^1.19.7",
64
+ "@modelcontextprotocol/sdk": "^1.0.1",
65
+ "axios": "^1.6.0",
66
+ "commander": "^11.1.0",
67
+ "dotenv": "^16.3.1",
68
+ "express": "^5.2.1",
69
+ "zod": "^3.22.0"
70
+ },
71
+ "devDependencies": {
72
+ "@types/express": "^5.0.6",
73
+ "@types/node": "^20.0.0",
74
+ "typescript": "^5.0.0",
75
+ "vitest": "^2.0.0"
76
+ }
77
+ }