@glie/mcp-polaris 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.
Files changed (4) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +59 -0
  3. package/dist/index.js +313 -0
  4. package/package.json +29 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work, excluding
103
+ those notices that do not pertain to any part of the Derivative
104
+ Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and do
117
+ not modify the License. You may add Your own attribution notices
118
+ within Derivative Works that You distribute, alongside or as an
119
+ addendum to the NOTICE text from the Work, provided that such
120
+ additional attribution notices cannot be construed as modifying
121
+ the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 glie
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,59 @@
1
+ # @glie/mcp-polaris
2
+
3
+ A [Model Context Protocol](https://modelcontextprotocol.io) (stdio) server that
4
+ exposes **Polaris** — glie's ops platform — as native tools inside Claude Code,
5
+ Cursor, or any MCP client. You authenticate as yourself with a Personal Access
6
+ Token, and the agent can list/transition tasks, validate approval stacks, and
7
+ approve work without leaving the editor.
8
+
9
+ ## Quick start
10
+
11
+ Add this to your project's `.mcp.json` (or your Claude Code config). The token
12
+ is read from the environment, so nothing secret is committed:
13
+
14
+ ```json
15
+ {
16
+ "mcpServers": {
17
+ "polaris": {
18
+ "command": "npx",
19
+ "args": ["-y", "@glie/mcp-polaris@latest"],
20
+ "env": {
21
+ "POLARIS_URL": "https://polaris.glie.ai",
22
+ "POLARIS_TOKEN": "${POLARIS_TOKEN}"
23
+ }
24
+ }
25
+ }
26
+ }
27
+ ```
28
+
29
+ Then export your token and start your editor from that shell:
30
+
31
+ ```bash
32
+ export POLARIS_TOKEN='polaris_h_…' # your Personal Access Token
33
+ ```
34
+
35
+ ## Getting a token
36
+
37
+ Open <https://polaris.glie.ai>, click the gear (top-right) → **/user/settings**
38
+ → **Personal access tokens** → create one. The secret is shown **once** — copy
39
+ it. The same token authenticates this server and the `polaris` CLI as you.
40
+
41
+ ## Configuration
42
+
43
+ | Env var | Default | Notes |
44
+ | --------------- | --------------------------- | -------------------------------------- |
45
+ | `POLARIS_URL` | `http://127.0.0.1:7843` | Set to `https://polaris.glie.ai`. |
46
+ | `POLARIS_TOKEN` | _(none)_ | PAT. Read tools work anonymously; writes need it. |
47
+
48
+ ## Tools
49
+
50
+ `polaris.me`, `polaris.project.*`, `polaris.milestone.*`, `polaris.task.*`
51
+ (incl. `approve`), `polaris.stack.*` (`list` / `get` / `release` / `reject` for
52
+ the approval Release Candidate flow), `polaris.agent.*`, `polaris.claude_md.get`,
53
+ `polaris.framework.list`.
54
+
55
+ Run `tools/list` against the server for the full, current set.
56
+
57
+ ## License
58
+
59
+ Apache-2.0
package/dist/index.js ADDED
@@ -0,0 +1,313 @@
1
+ #!/usr/bin/env node
2
+ // @bun
3
+
4
+ // ../../src/mcp/index.ts
5
+ import { createInterface } from "readline";
6
+ var BASE = process.env.POLARIS_URL ?? "http://127.0.0.1:7843";
7
+ var TOKEN = process.env.POLARIS_TOKEN ?? "";
8
+ var log = (msg, ctx) => process.stderr.write(`mcp-polaris: ${msg}${ctx ? ` ${JSON.stringify(ctx)}` : ""}
9
+ `);
10
+ async function apiCall(method, path, body) {
11
+ const headers = { Accept: "application/json" };
12
+ if (TOKEN)
13
+ headers.Authorization = `Bearer ${TOKEN}`;
14
+ if (body !== undefined)
15
+ headers["Content-Type"] = "application/json";
16
+ const res = await fetch(`${BASE}${path}`, {
17
+ method,
18
+ headers,
19
+ body: body === undefined ? undefined : JSON.stringify(body)
20
+ });
21
+ const text = await res.text();
22
+ let parsed = text;
23
+ if (text) {
24
+ try {
25
+ parsed = JSON.parse(text);
26
+ } catch {}
27
+ }
28
+ return { status: res.status, body: parsed };
29
+ }
30
+ function strSchema(description) {
31
+ return { type: "string", ...description ? { description } : {} };
32
+ }
33
+ function intSchema(description) {
34
+ return { type: "integer", ...description ? { description } : {} };
35
+ }
36
+ function objSchema(properties, required = []) {
37
+ return {
38
+ type: "object",
39
+ properties,
40
+ ...required.length ? { required } : {},
41
+ additionalProperties: false
42
+ };
43
+ }
44
+ var TOOLS = [
45
+ {
46
+ name: "polaris.me",
47
+ description: "Get the current authenticated human (PAT owner).",
48
+ inputSchema: objSchema({}),
49
+ call: async () => {
50
+ const r = await apiCall("GET", "/api/humans/me");
51
+ return r.body;
52
+ }
53
+ },
54
+ {
55
+ name: "polaris.project.list",
56
+ description: "List projects. Filter by status optional.",
57
+ inputSchema: objSchema({
58
+ status: strSchema("active|paused|archived"),
59
+ limit: intSchema()
60
+ }),
61
+ call: async (args) => {
62
+ const qs = new URLSearchParams;
63
+ if (typeof args.status === "string")
64
+ qs.set("status", args.status);
65
+ if (typeof args.limit === "number")
66
+ qs.set("limit", String(args.limit));
67
+ const r = await apiCall("GET", `/api/projects${qs.toString() ? `?${qs}` : ""}`);
68
+ return r.body;
69
+ }
70
+ },
71
+ {
72
+ name: "polaris.project.get",
73
+ description: "Get one project by key.",
74
+ inputSchema: objSchema({ key: strSchema("project key (e.g. saasA)") }, ["key"]),
75
+ call: async (args) => (await apiCall("GET", `/api/projects/${args.key}`)).body
76
+ },
77
+ {
78
+ name: "polaris.project.create",
79
+ description: "Create a project (human-only).",
80
+ inputSchema: objSchema({ key: strSchema(), name: strSchema(), description_md: strSchema() }, [
81
+ "key",
82
+ "name"
83
+ ]),
84
+ call: async (args) => (await apiCall("POST", "/api/projects", args)).body
85
+ },
86
+ {
87
+ name: "polaris.milestone.list",
88
+ description: "List milestones in a project.",
89
+ inputSchema: objSchema({ project_key: strSchema() }, ["project_key"]),
90
+ call: async (args) => (await apiCall("GET", `/api/projects/${args.project_key}/milestones?limit=200`)).body
91
+ },
92
+ {
93
+ name: "polaris.milestone.get",
94
+ description: "Get one milestone by id.",
95
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
96
+ call: async (args) => (await apiCall("GET", `/api/milestones/${args.id}`)).body
97
+ },
98
+ {
99
+ name: "polaris.milestone.transition",
100
+ description: "Transition milestone status (state machine enforced: draft\u2192discovery\u2192loop\u2192release\u2192done, *\u2192canceled).",
101
+ inputSchema: objSchema({ id: intSchema(), status: strSchema() }, ["id", "status"]),
102
+ call: async (args) => (await apiCall("POST", `/api/milestones/${args.id}/state`, { status: args.status })).body
103
+ },
104
+ {
105
+ name: "polaris.milestone.qa_list",
106
+ description: "List framework Q&A rows for a milestone.",
107
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
108
+ call: async (args) => (await apiCall("GET", `/api/milestones/${args.id}/framework-qa`)).body
109
+ },
110
+ {
111
+ name: "polaris.milestone.qa_answer",
112
+ description: "Answer a framework Q&A row (milestone must be in discovery).",
113
+ inputSchema: objSchema({ id: intSchema(), question_id: intSchema(), answer_md: strSchema() }, [
114
+ "id",
115
+ "question_id",
116
+ "answer_md"
117
+ ]),
118
+ call: async (args) => (await apiCall("PATCH", `/api/milestones/${args.id}/framework-qa/${args.question_id}`, {
119
+ answer_md: args.answer_md
120
+ })).body
121
+ },
122
+ {
123
+ name: "polaris.task.list",
124
+ description: "List tasks across milestones. Filter by status/product/team/assignee.",
125
+ inputSchema: objSchema({
126
+ status: strSchema("comma-separated: backlog,dev,test,..."),
127
+ milestone_id: intSchema(),
128
+ product_key: strSchema(),
129
+ team: strSchema("dev|mkt"),
130
+ limit: intSchema()
131
+ }),
132
+ call: async (args) => {
133
+ const qs = new URLSearchParams;
134
+ for (const k of ["status", "milestone_id", "product_key", "team", "limit"]) {
135
+ const v = args[k];
136
+ if (v !== undefined && v !== null)
137
+ qs.set(k, String(v));
138
+ }
139
+ const r = await apiCall("GET", `/api/tasks${qs.toString() ? `?${qs}` : ""}`);
140
+ return r.body;
141
+ }
142
+ },
143
+ {
144
+ name: "polaris.task.get",
145
+ description: "Get one task by id.",
146
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
147
+ call: async (args) => (await apiCall("GET", `/api/tasks/${args.id}`)).body
148
+ },
149
+ {
150
+ name: "polaris.task.create",
151
+ description: "Create a task within a milestone.",
152
+ inputSchema: objSchema({ milestone_id: intSchema(), name: strSchema(), description_md: strSchema() }, ["milestone_id", "name"]),
153
+ call: async (args) => (await apiCall("POST", "/api/tasks", args)).body
154
+ },
155
+ {
156
+ name: "polaris.task.transition",
157
+ description: "Transition task status (state machine enforced).",
158
+ inputSchema: objSchema({ id: intSchema(), status: strSchema() }, ["id", "status"]),
159
+ call: async (args) => (await apiCall("POST", `/api/tasks/${args.id}/state`, { status: args.status })).body
160
+ },
161
+ {
162
+ name: "polaris.task.approve",
163
+ description: "Approve a task in approval state (human-only).",
164
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
165
+ call: async (args) => (await apiCall("POST", `/api/tasks/${args.id}/approve`)).body
166
+ },
167
+ {
168
+ name: "polaris.task.dep_add",
169
+ description: "Add a dependency edge (cycle-checked).",
170
+ inputSchema: objSchema({ id: intSchema(), dep_task_id: intSchema() }, ["id", "dep_task_id"]),
171
+ call: async (args) => (await apiCall("POST", `/api/tasks/${args.id}/deps`, { dep_task_id: args.dep_task_id })).body
172
+ },
173
+ {
174
+ name: "polaris.task.dep_remove",
175
+ description: "Remove a dependency edge (idempotent).",
176
+ inputSchema: objSchema({ id: intSchema(), dep_task_id: intSchema() }, ["id", "dep_task_id"]),
177
+ call: async (args) => (await apiCall("DELETE", `/api/tasks/${args.id}/deps/${args.dep_task_id}`)).body
178
+ },
179
+ {
180
+ name: "polaris.stack.list",
181
+ description: "List approval stacks (Release Candidates). Filter by status: liquid|frozen|released|canceled.",
182
+ inputSchema: objSchema({ status: strSchema("liquid|frozen|released|canceled") }),
183
+ call: async (args) => {
184
+ const qs = typeof args.status === "string" ? `?status=${encodeURIComponent(args.status)}` : "";
185
+ return (await apiCall("GET", `/api/stacks${qs}`)).body;
186
+ }
187
+ },
188
+ {
189
+ name: "polaris.stack.get",
190
+ description: "Get one approval stack by id \u2014 includes its member tasks and the rc integration branch.",
191
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
192
+ call: async (args) => (await apiCall("GET", `/api/stacks/${args.id}`)).body
193
+ },
194
+ {
195
+ name: "polaris.stack.release",
196
+ description: "Release a stack \u2014 merge its rc branch to dev and settle members to release (human-only).",
197
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
198
+ call: async (args) => (await apiCall("POST", `/api/stacks/${args.id}/release`)).body
199
+ },
200
+ {
201
+ name: "polaris.stack.reject",
202
+ description: "Reject a stack \u2014 return its member tasks to their prior state (human-only).",
203
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
204
+ call: async (args) => (await apiCall("POST", `/api/stacks/${args.id}/reject`)).body
205
+ },
206
+ {
207
+ name: "polaris.agent.list",
208
+ description: "List agents.",
209
+ inputSchema: objSchema({}),
210
+ call: async () => (await apiCall("GET", "/api/agents?limit=200")).body
211
+ },
212
+ {
213
+ name: "polaris.agent.get",
214
+ description: "Get one agent by id.",
215
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
216
+ call: async (args) => (await apiCall("GET", `/api/agents/${args.id}`)).body
217
+ },
218
+ {
219
+ name: "polaris.agent.token_list",
220
+ description: "List service tokens for an agent (no plaintext, human-only).",
221
+ inputSchema: objSchema({ id: intSchema() }, ["id"]),
222
+ call: async (args) => (await apiCall("GET", `/api/agents/${args.id}/tokens`)).body
223
+ },
224
+ {
225
+ name: "polaris.claude_md.get",
226
+ description: "Read the CLAUDE.md of a project (via polaris-bot).",
227
+ inputSchema: objSchema({ project_key: strSchema() }, ["project_key"]),
228
+ call: async (args) => (await apiCall("GET", `/api/projects/${args.project_key}/claude-md`)).body
229
+ },
230
+ {
231
+ name: "polaris.framework.list",
232
+ description: "List the curated frameworks (knowledge bases).",
233
+ inputSchema: objSchema({}),
234
+ call: async () => (await apiCall("GET", "/api/frameworks")).body
235
+ }
236
+ ];
237
+ var TOOLS_BY_NAME = new Map(TOOLS.map((t) => [t.name, t]));
238
+ function send(msg) {
239
+ process.stdout.write(`${JSON.stringify(msg)}
240
+ `);
241
+ }
242
+ function ok(id, result) {
243
+ return { jsonrpc: "2.0", id, result };
244
+ }
245
+ function fail(id, code, message, data) {
246
+ return { jsonrpc: "2.0", id, error: { code, message, ...data ? { data } : {} } };
247
+ }
248
+ async function handle(req) {
249
+ const id = req.id ?? null;
250
+ switch (req.method) {
251
+ case "initialize":
252
+ return ok(id, {
253
+ protocolVersion: "2024-11-05",
254
+ capabilities: { tools: {} },
255
+ serverInfo: { name: "mcp-polaris", version: "0.1.0" }
256
+ });
257
+ case "initialized":
258
+ return null;
259
+ case "tools/list":
260
+ return ok(id, {
261
+ tools: TOOLS.map((t) => ({
262
+ name: t.name,
263
+ description: t.description,
264
+ inputSchema: t.inputSchema
265
+ }))
266
+ });
267
+ case "tools/call": {
268
+ const name = req.params?.name;
269
+ const args = req.params?.arguments ?? {};
270
+ if (!name)
271
+ return fail(id, -32602, "missing tool name");
272
+ const tool = TOOLS_BY_NAME.get(name);
273
+ if (!tool)
274
+ return fail(id, -32601, `unknown tool: ${name}`);
275
+ try {
276
+ const result = await tool.call(args);
277
+ return ok(id, {
278
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }]
279
+ });
280
+ } catch (err) {
281
+ return fail(id, -32603, err.message);
282
+ }
283
+ }
284
+ case "ping":
285
+ return ok(id, {});
286
+ default:
287
+ return fail(id, -32601, `method not found: ${req.method}`);
288
+ }
289
+ }
290
+ log(`starting against ${BASE} (token=${TOKEN ? "set" : "none"})`);
291
+ var rl = createInterface({ input: process.stdin, crlfDelay: Number.POSITIVE_INFINITY });
292
+ rl.on("line", async (line) => {
293
+ if (!line.trim())
294
+ return;
295
+ let req;
296
+ try {
297
+ req = JSON.parse(line);
298
+ } catch (_err) {
299
+ send(fail(null, -32700, "parse error", { line }));
300
+ return;
301
+ }
302
+ try {
303
+ const res = await handle(req);
304
+ if (res)
305
+ send(res);
306
+ } catch (err) {
307
+ send(fail(req.id ?? null, -32603, err.message));
308
+ }
309
+ });
310
+ rl.on("close", () => log("stdin closed, exiting"));
311
+ export {
312
+ TOOLS
313
+ };
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@glie/mcp-polaris",
3
+ "version": "0.1.0",
4
+ "description": "Model Context Protocol (stdio) server exposing Polaris — glie's ops platform — as native tools in Claude Code and any MCP client.",
5
+ "license": "Apache-2.0",
6
+ "author": "glie <carlos@glie.ai>",
7
+ "type": "module",
8
+ "bin": {
9
+ "mcp-polaris": "dist/index.js"
10
+ },
11
+ "files": ["dist", "README.md", "LICENSE"],
12
+ "engines": {
13
+ "node": ">=18"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/glieai/polaris.git",
21
+ "directory": "packages/mcp-polaris"
22
+ },
23
+ "homepage": "https://polaris.glie.ai",
24
+ "keywords": ["mcp", "model-context-protocol", "claude", "claude-code", "polaris", "glie"],
25
+ "scripts": {
26
+ "build": "bun run build.ts",
27
+ "prepublishOnly": "bun run build.ts"
28
+ }
29
+ }