@gopersonal/advisor 1.0.2 → 1.0.4

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.
Files changed (3) hide show
  1. package/README.md +63 -17
  2. package/build/index.js +17 -3
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,47 +7,64 @@ An MCP server that gives AI agents access to a separate AI advisor via [OpenCode
7
7
  - **ask_advisor** — Get help when stuck after multiple failed attempts
8
8
  - **get_second_opinion** — Sanity-check a decision between approaches
9
9
 
10
- ## Add to Claude Code
11
-
12
- ### Option A: OpenAI endpoint
10
+ ## Quick Start
13
11
 
14
12
  ```bash
15
13
  claude mcp add advisor \
16
14
  -e ADVISOR_PROVIDER=openai \
17
15
  -e ADVISOR_MODEL=gpt-4o \
18
16
  -e ADVISOR_API_KEY=sk-your-key \
17
+ -e ADVISOR_BASE_URL=https://api.openai.com/v1 \
19
18
  -- npx -y @gopersonal/advisor
20
19
  ```
21
20
 
22
- With a custom OpenAI-compatible endpoint:
21
+ ## Setup
22
+
23
+ ### Option A: OpenAI-compatible endpoint
24
+
25
+ Works with OpenAI, MiniMax, Together, Groq, and any `/v1/chat/completions` endpoint.
23
26
 
24
27
  ```bash
25
28
  claude mcp add advisor \
26
29
  -e ADVISOR_PROVIDER=openai \
27
30
  -e ADVISOR_MODEL=gpt-4o \
28
31
  -e ADVISOR_API_KEY=sk-your-key \
29
- -e ADVISOR_BASE_URL=https://your-openai-proxy.example.com/v1 \
32
+ -e ADVISOR_BASE_URL=https://api.openai.com/v1 \
33
+ -- npx -y @gopersonal/advisor
34
+ ```
35
+
36
+ Example with MiniMax (tested):
37
+
38
+ ```bash
39
+ claude mcp add advisor \
40
+ -e ADVISOR_PROVIDER=openai \
41
+ -e ADVISOR_MODEL=MiniMax-M2.5 \
42
+ -e ADVISOR_API_KEY=sk-your-minimax-key \
43
+ -e ADVISOR_BASE_URL=https://api.minimax.io/v1 \
30
44
  -- npx -y @gopersonal/advisor
31
45
  ```
32
46
 
33
- ### Option B: Anthropic endpoint
47
+ ### Option B: Anthropic-compatible endpoint
48
+
49
+ Works with Anthropic and any `/v1/messages` endpoint.
34
50
 
35
51
  ```bash
36
52
  claude mcp add advisor \
37
53
  -e ADVISOR_PROVIDER=anthropic \
38
54
  -e ADVISOR_MODEL=claude-sonnet-4-5 \
39
55
  -e ADVISOR_API_KEY=sk-ant-your-key \
56
+ -e ADVISOR_BASE_URL=https://api.anthropic.com \
40
57
  -- npx -y @gopersonal/advisor
41
58
  ```
42
59
 
43
- With a custom Anthropic-compatible endpoint:
60
+ Example with a proxy (tested):
44
61
 
45
62
  ```bash
46
63
  claude mcp add advisor \
47
64
  -e ADVISOR_PROVIDER=anthropic \
48
- -e ADVISOR_MODEL=claude-sonnet-4-5 \
65
+ -e ADVISOR_MODEL=gpt-5.2-codex \
49
66
  -e ADVISOR_API_KEY=none \
50
- -e ADVISOR_BASE_URL=https://your-anthropic-proxy.example.com \
67
+ -e ADVISOR_BASE_URL=https://azure-openai-anthropic-proxy.go-shops.workers.dev \
51
68
  -- npx -y @gopersonal/advisor
52
69
  ```
53
70
 
@@ -57,25 +74,54 @@ claude mcp add advisor \
57
74
  claude mcp add advisor -- npx -y @gopersonal/advisor
58
75
  ```
59
76
 
77
+ ### With project context and instructions
78
+
79
+ Give the advisor context about your project so it can provide more relevant advice:
80
+
81
+ ```bash
82
+ claude mcp add advisor \
83
+ -e ADVISOR_PROVIDER=anthropic \
84
+ -e ADVISOR_MODEL=gpt-5.2-codex \
85
+ -e ADVISOR_API_KEY=none \
86
+ -e ADVISOR_BASE_URL=https://azure-openai-anthropic-proxy.go-shops.workers.dev \
87
+ -e ADVISOR_DIRECTORY=/Users/me/myproject \
88
+ -e ADVISOR_INSTRUCTIONS=/Users/me/myproject/AGENTS.md \
89
+ -- npx -y @gopersonal/advisor
90
+ ```
91
+
60
92
  ## Environment Variables
61
93
 
62
- | Variable | Description | Example |
63
- |---|---|---|
64
- | `ADVISOR_PROVIDER` | `openai` or `anthropic` | `openai` |
65
- | `ADVISOR_MODEL` | Model name | `gpt-4o`, `claude-sonnet-4-5` |
66
- | `ADVISOR_API_KEY` | API key for the provider | `sk-...` |
67
- | `ADVISOR_BASE_URL` | Custom base URL (optional) | `https://proxy.example.com` |
94
+ | Variable | Required | Description | Example |
95
+ |---|---|---|---|
96
+ | `ADVISOR_PROVIDER` | Yes | `openai` or `anthropic` | `openai` |
97
+ | `ADVISOR_MODEL` | Yes | Model name | `gpt-4o`, `claude-sonnet-4-5` |
98
+ | `ADVISOR_API_KEY` | Yes | API key for the provider | `sk-...` |
99
+ | `ADVISOR_BASE_URL` | Yes | API base URL | `https://api.openai.com/v1` |
100
+ | `ADVISOR_DIRECTORY` | No | Project directory for opencode context | `/Users/me/myproject` |
101
+ | `ADVISOR_INSTRUCTIONS` | No | Path to instructions file (AGENTS.md, etc.) | `/Users/me/myproject/AGENTS.md` |
102
+
103
+ - `ADVISOR_PROVIDER` determines the API format: `openai` uses `/v1/chat/completions`, `anthropic` uses `/v1/messages`
104
+ - `ADVISOR_DIRECTORY` gives the advisor access to your project files and structure
105
+ - `ADVISOR_INSTRUCTIONS` loads a custom instructions file so the advisor knows your project conventions
68
106
 
69
107
  If no env vars are set, the advisor connects to a running opencode instance or starts one using your default opencode config.
70
108
 
71
109
  ## How it works
72
110
 
73
111
  1. Agent calls `ask_advisor` or `get_second_opinion` via MCP
74
- 2. The server creates a temporary OpenCode session
112
+ 2. The server creates a temporary OpenCode session (scoped to `ADVISOR_DIRECTORY` if set)
75
113
  3. Sends the prompt asynchronously, polls for the response
76
114
  4. Auto-answers any interactive questions from the OpenCode agent
77
115
  5. Returns the advisor's response and cleans up the session
78
116
 
117
+ ## Tested configurations
118
+
119
+ | Provider | Model | Base URL | Status |
120
+ |---|---|---|---|
121
+ | `anthropic` | `gpt-5.2-codex` | `azure-openai-anthropic-proxy.go-shops.workers.dev` | Working |
122
+ | `openai` | `MiniMax-M2.5` | `api.minimax.io/v1` | Working |
123
+ | `anthropic` | `gpt-5.2-codex` | proxy + `ADVISOR_DIRECTORY` + `ADVISOR_INSTRUCTIONS` | Working |
124
+
79
125
  ## Requirements
80
126
 
81
127
  - [OpenCode](https://opencode.ai) installed (`brew install sst/tap/opencode` or `npm i -g opencode`)
@@ -103,7 +149,7 @@ claude mcp add advisor -- node /path/to/advisor/build/index.js
103
149
  npm login
104
150
  ```
105
151
 
106
- 2. Update the version in `package.json`:
152
+ 2. Update the version:
107
153
 
108
154
  ```bash
109
155
  npm version patch # 1.0.0 -> 1.0.1 (bug fixes)
package/build/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 { z } from "zod";
5
5
  import { createOpencode, createOpencodeClient } from "@opencode-ai/sdk/v2";
6
+ import { existsSync } from "fs";
6
7
  // --- Environment-based configuration ---
7
8
  //
8
9
  // Pass these via the "env" field in the MCP config JSON.
@@ -19,8 +20,9 @@ import { createOpencode, createOpencodeClient } from "@opencode-ai/sdk/v2";
19
20
  // ADVISOR_API_KEY = "sk-ant-..."
20
21
  // ADVISOR_BASE_URL = "https://api.anthropic.com"
21
22
  //
22
- // ADVISOR_BASE_URL is required when using a custom/proxy endpoint.
23
- // If omitted, the default API URL for the provider is used.
23
+ // Optional:
24
+ // ADVISOR_DIRECTORY = project directory for opencode context (e.g. "/Users/me/myproject")
25
+ // ADVISOR_INSTRUCTIONS = path to instructions file (e.g. "/Users/me/myproject/AGENTS.md")
24
26
  //
25
27
  function resolveProviderAndModel() {
26
28
  const explicitProvider = process.env.ADVISOR_PROVIDER?.toLowerCase();
@@ -67,10 +69,18 @@ function buildOpencodeConfig() {
67
69
  const apiKey = process.env.ADVISOR_API_KEY;
68
70
  const baseURL = process.env.ADVISOR_BASE_URL;
69
71
  const npm = process.env.ADVISOR_NPM || resolved?.npm;
72
+ const instructionsPath = process.env.ADVISOR_INSTRUCTIONS;
73
+ const instructions = instructionsPath && existsSync(instructionsPath) ? instructionsPath : undefined;
70
74
  const config = {
71
75
  // Disable title generation (it uses small_model which may not work with custom providers)
72
76
  small_model: resolved?.fullModel || undefined,
77
+ // Additional instruction files (e.g. AGENTS.md)
78
+ ...(instructions ? { instructions: [instructions] } : {}),
73
79
  };
80
+ if (instructions)
81
+ console.error(`[advisor] Instructions: ${instructions}`);
82
+ if (instructionsPath && !instructions)
83
+ console.error(`[advisor] Instructions file not found: ${instructionsPath}, skipping`);
74
84
  if (resolved) {
75
85
  config.model = resolved.fullModel;
76
86
  console.error(`[advisor] Provider: ${resolved.provider}, Model: ${resolved.model}`);
@@ -162,8 +172,10 @@ function sleep(ms) {
162
172
  }
163
173
  async function askOpencode(prompt, systemPrompt) {
164
174
  const client = await getOpencodeClient();
175
+ const directory = process.env.ADVISOR_DIRECTORY;
165
176
  const sessionResult = await client.session.create({
166
177
  title: "Advisor Query",
178
+ ...(directory ? { directory } : {}),
167
179
  });
168
180
  if (!sessionResult.data) {
169
181
  throw new Error("Failed to create opencode session");
@@ -177,6 +189,7 @@ async function askOpencode(prompt, systemPrompt) {
177
189
  sessionID: sessionId,
178
190
  system: systemPrompt,
179
191
  ...(modelOverride ? { model: modelOverride } : {}),
192
+ ...(directory ? { directory } : {}),
180
193
  parts: [{ type: "text", text: prompt }],
181
194
  });
182
195
  console.error(`[advisor] Prompt submitted async`);
@@ -392,7 +405,8 @@ server.registerTool("get_second_opinion", {
392
405
  async function main() {
393
406
  const transport = new StdioServerTransport();
394
407
  await server.connect(transport);
395
- console.error("[advisor] MCP Advisor server running on stdio");
408
+ const dir = process.env.ADVISOR_DIRECTORY;
409
+ console.error(`[advisor] MCP Advisor server running on stdio${dir ? ` (directory: ${dir})` : ""}`);
396
410
  }
397
411
  main().catch((error) => {
398
412
  console.error("[advisor] Fatal error:", error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gopersonal/advisor",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "type": "module",
5
5
  "main": "./build/index.js",
6
6
  "bin": {