@kolbo/mcp 1.17.2 → 1.18.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/package.json +1 -1
- package/src/client.js +16 -3
- package/src/index.js +21 -3
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -144,11 +144,21 @@ function readCliAuthKey() {
|
|
|
144
144
|
// ---------------------------------------------------------------------------
|
|
145
145
|
|
|
146
146
|
class KolboClient {
|
|
147
|
-
|
|
148
|
-
|
|
147
|
+
/**
|
|
148
|
+
* @param {object} [opts]
|
|
149
|
+
* @param {string} [opts.apiKey] Explicit key. Takes precedence over env +
|
|
150
|
+
* auth store. Used by a remote HTTP host that injects the caller's key per
|
|
151
|
+
* request (one KolboClient per request) instead of reading a process-wide
|
|
152
|
+
* env var. When set, the auth-store 401 refresh path is disabled — the host
|
|
153
|
+
* owns the key lifecycle.
|
|
154
|
+
* @param {string} [opts.apiBase] Explicit API base URL override.
|
|
155
|
+
*/
|
|
156
|
+
constructor(opts = {}) {
|
|
157
|
+
this.baseUrl = opts.apiBase ? String(opts.apiBase).replace(/\/$/, '') : resolveApiBase();
|
|
158
|
+
this._explicitKey = opts.apiKey || null;
|
|
149
159
|
this._envKey = process.env.KOLBO_API_KEY || null;
|
|
150
160
|
this._authStoreKey = null; // lazy-loaded
|
|
151
|
-
this.apiKey = this._envKey || this._readAuthStore();
|
|
161
|
+
this.apiKey = this._explicitKey || this._envKey || this._readAuthStore();
|
|
152
162
|
|
|
153
163
|
if (!this.apiKey) {
|
|
154
164
|
// No key in env OR auth store. The Kolbo Code parent process should
|
|
@@ -171,6 +181,9 @@ class KolboClient {
|
|
|
171
181
|
* since the MCP server started. Returns true if a new key was found.
|
|
172
182
|
*/
|
|
173
183
|
_tryRefreshKey() {
|
|
184
|
+
// Host-injected per-request key is authoritative — never override it from
|
|
185
|
+
// the local CLI auth store (which may not even exist in a server context).
|
|
186
|
+
if (this._explicitKey) return false;
|
|
174
187
|
if (this._envKey) {
|
|
175
188
|
// Env var is set but invalid — can't override it, but try auth store
|
|
176
189
|
const fresh = readCliAuthKey();
|
package/src/index.js
CHANGED
|
@@ -70,8 +70,20 @@ const { registerAppBuilderTools } = require('./tools/app_builder');
|
|
|
70
70
|
const { registerArtifactTools } = require('./tools/artifacts');
|
|
71
71
|
const { registerProjectTools } = require('./tools/projects');
|
|
72
72
|
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
/**
|
|
74
|
+
* Build a fully-configured Kolbo MCP server (all tool groups registered)
|
|
75
|
+
* WITHOUT connecting a transport. This is the reusable core shared by:
|
|
76
|
+
* - the stdio entrypoint below (npx / Kolbo Code), and
|
|
77
|
+
* - a remote HTTP host (kolbo-api) that creates one server per request with
|
|
78
|
+
* the caller's key injected via `opts.apiKey`.
|
|
79
|
+
*
|
|
80
|
+
* @param {object} [opts]
|
|
81
|
+
* @param {string} [opts.apiKey] Per-instance Kolbo API key (overrides env).
|
|
82
|
+
* @param {string} [opts.apiBase] API base URL override.
|
|
83
|
+
* @returns {McpServer} a server ready to `.connect(transport)`.
|
|
84
|
+
*/
|
|
85
|
+
function createServer(opts = {}) {
|
|
86
|
+
const client = new KolboClient(opts);
|
|
75
87
|
|
|
76
88
|
const server = new McpServer({
|
|
77
89
|
name: 'kolbo',
|
|
@@ -90,12 +102,18 @@ async function main() {
|
|
|
90
102
|
registerArtifactTools(server, client);
|
|
91
103
|
registerProjectTools(server, client);
|
|
92
104
|
|
|
105
|
+
return server;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async function main() {
|
|
109
|
+
const server = createServer();
|
|
110
|
+
|
|
93
111
|
// Start the server with stdio transport
|
|
94
112
|
const transport = new StdioServerTransport();
|
|
95
113
|
await server.connect(transport);
|
|
96
114
|
}
|
|
97
115
|
|
|
98
|
-
module.exports = { main };
|
|
116
|
+
module.exports = { main, createServer };
|
|
99
117
|
|
|
100
118
|
// Auto-run when invoked directly (e.g. `node src/index.js` or via the published
|
|
101
119
|
// bin/kolbo-mcp.js wrapper). Consumers that `require()` this module to embed it
|