substrate-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.
Files changed (46) hide show
  1. package/README.md +249 -0
  2. package/dist/config.d.ts +16 -0
  3. package/dist/config.d.ts.map +1 -0
  4. package/dist/config.js +44 -0
  5. package/dist/config.js.map +1 -0
  6. package/dist/index.d.ts +3 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +38 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/prompts.d.ts +7 -0
  11. package/dist/prompts.d.ts.map +1 -0
  12. package/dist/prompts.js +172 -0
  13. package/dist/prompts.js.map +1 -0
  14. package/dist/resources.d.ts +8 -0
  15. package/dist/resources.d.ts.map +1 -0
  16. package/dist/resources.js +82 -0
  17. package/dist/resources.js.map +1 -0
  18. package/dist/substrate-client.d.ts +39 -0
  19. package/dist/substrate-client.d.ts.map +1 -0
  20. package/dist/substrate-client.js +122 -0
  21. package/dist/substrate-client.js.map +1 -0
  22. package/dist/tools/backlog.d.ts +4 -0
  23. package/dist/tools/backlog.d.ts.map +1 -0
  24. package/dist/tools/backlog.js +146 -0
  25. package/dist/tools/backlog.js.map +1 -0
  26. package/dist/tools/get-context.d.ts +11 -0
  27. package/dist/tools/get-context.d.ts.map +1 -0
  28. package/dist/tools/get-context.js +35 -0
  29. package/dist/tools/get-context.js.map +1 -0
  30. package/dist/tools/investigations.d.ts +4 -0
  31. package/dist/tools/investigations.d.ts.map +1 -0
  32. package/dist/tools/investigations.js +148 -0
  33. package/dist/tools/investigations.js.map +1 -0
  34. package/dist/tools/nanopubs.d.ts +12 -0
  35. package/dist/tools/nanopubs.d.ts.map +1 -0
  36. package/dist/tools/nanopubs.js +56 -0
  37. package/dist/tools/nanopubs.js.map +1 -0
  38. package/dist/tools/sync.d.ts +10 -0
  39. package/dist/tools/sync.d.ts.map +1 -0
  40. package/dist/tools/sync.js +34 -0
  41. package/dist/tools/sync.js.map +1 -0
  42. package/dist/types.d.ts +278 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/types.js +6 -0
  45. package/dist/types.js.map +1 -0
  46. package/package.json +29 -0
@@ -0,0 +1,39 @@
1
+ import type { AuthenticateResponse, BacklogItemResponse, CreateBacklogItemPayload, CreateInvestigationPayload, GetContextResponse, InvestigationResponse, ListBacklogResponse, RequestSyncResponse } from "./types.js";
2
+ export declare class SubstrateApiError extends Error {
3
+ readonly statusCode: number;
4
+ readonly errorCode: string;
5
+ constructor(statusCode: number, errorCode: string, message: string);
6
+ }
7
+ export declare class SubstrateClient {
8
+ private readonly baseUrl;
9
+ private readonly token;
10
+ constructor(baseUrl: string, token: string);
11
+ private request;
12
+ /** GET /api/agent – verify the bearer token and return agent metadata. */
13
+ authenticate(): Promise<AuthenticateResponse>;
14
+ /** GET /api/agent/context – fetch the full room context pack. */
15
+ getContext(): Promise<GetContextResponse>;
16
+ /** GET /api/agent/backlog – list all backlog items in the room. */
17
+ listBacklog(): Promise<ListBacklogResponse>;
18
+ /** POST /api/agent/backlog – create a new backlog item. */
19
+ createBacklogItem(payload: CreateBacklogItemPayload): Promise<BacklogItemResponse>;
20
+ /** POST /api/agent/backlog/:id/claim – claim a backlog item. */
21
+ claimBacklogItem(id: string): Promise<BacklogItemResponse>;
22
+ /** DELETE /api/agent/backlog/:id/claim – release a backlog claim. */
23
+ releaseBacklogClaim(id: string): Promise<BacklogItemResponse>;
24
+ /** POST /api/agent/investigations – register a new investigation. */
25
+ createInvestigation(payload: CreateInvestigationPayload): Promise<InvestigationResponse>;
26
+ /** PATCH /api/agent/investigations/:id – heartbeat an investigation. */
27
+ heartbeatInvestigation(id: string): Promise<InvestigationResponse>;
28
+ /** PATCH /api/agent/investigations/:id – complete an investigation. */
29
+ completeInvestigation(id: string): Promise<InvestigationResponse>;
30
+ /** DELETE /api/agent/investigations/:id – abandon an investigation. */
31
+ abandonInvestigation(id: string): Promise<InvestigationResponse>;
32
+ /** POST /api/agent/sync – request a room repo sync. */
33
+ requestSync(): Promise<RequestSyncResponse>;
34
+ listThreads(..._args: unknown[]): Promise<never>;
35
+ createThread(..._args: unknown[]): Promise<never>;
36
+ listThreadMessages(..._args: unknown[]): Promise<never>;
37
+ postThreadMessage(..._args: unknown[]): Promise<never>;
38
+ }
39
+ //# sourceMappingURL=substrate-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"substrate-client.d.ts","sourceRoot":"","sources":["../src/substrate-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EACpB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,kBAAkB,EAElB,qBAAqB,EACrB,mBAAmB,EACnB,mBAAmB,EAEpB,MAAM,YAAY,CAAC;AAMpB,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;gBAEf,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMnE;AAMD,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;gBAEnB,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;YAQ5B,OAAO;IAsCrB,0EAA0E;IACpE,YAAY,IAAI,OAAO,CAAC,oBAAoB,CAAC;IAMnD,iEAAiE;IAC3D,UAAU,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAM/C,mEAAmE;IAC7D,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAIjD,2DAA2D;IACrD,iBAAiB,CACrB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,mBAAmB,CAAC;IAQ/B,gEAAgE;IAC1D,gBAAgB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAOhE,qEAAqE;IAC/D,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC;IASnE,qEAAqE;IAC/D,mBAAmB,CACvB,OAAO,EAAE,0BAA0B,GAClC,OAAO,CAAC,qBAAqB,CAAC;IAQjC,wEAAwE;IAClE,sBAAsB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQxE,uEAAuE;IACjE,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQvE,uEAAuE;IACjE,oBAAoB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAStE,uDAAuD;IACjD,WAAW,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAO3C,WAAW,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IAKhD,YAAY,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IAKjD,kBAAkB,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;IAKvD,iBAAiB,CAAC,GAAG,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC;CAG7D"}
@@ -0,0 +1,122 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Error
3
+ // ---------------------------------------------------------------------------
4
+ export class SubstrateApiError extends Error {
5
+ statusCode;
6
+ errorCode;
7
+ constructor(statusCode, errorCode, message) {
8
+ super(message);
9
+ this.name = "SubstrateApiError";
10
+ this.statusCode = statusCode;
11
+ this.errorCode = errorCode;
12
+ }
13
+ }
14
+ // ---------------------------------------------------------------------------
15
+ // Client
16
+ // ---------------------------------------------------------------------------
17
+ export class SubstrateClient {
18
+ baseUrl;
19
+ token;
20
+ constructor(baseUrl, token) {
21
+ // Strip trailing slash for consistent URL construction.
22
+ this.baseUrl = baseUrl.replace(/\/+$/, "");
23
+ this.token = token;
24
+ }
25
+ // -- helpers --------------------------------------------------------------
26
+ async request(method, path, body) {
27
+ const url = `${this.baseUrl}${path}`;
28
+ const headers = {
29
+ Authorization: `Bearer ${this.token}`,
30
+ Accept: "application/json",
31
+ };
32
+ if (body !== undefined) {
33
+ headers["Content-Type"] = "application/json";
34
+ }
35
+ const res = await fetch(url, {
36
+ method,
37
+ headers,
38
+ body: body !== undefined ? JSON.stringify(body) : undefined,
39
+ });
40
+ if (!res.ok) {
41
+ let code = "unknown_error";
42
+ let message = res.statusText;
43
+ try {
44
+ const err = (await res.json());
45
+ code = err.error.code;
46
+ message = err.error.message;
47
+ }
48
+ catch {
49
+ // keep defaults
50
+ }
51
+ throw new SubstrateApiError(res.status, code, message);
52
+ }
53
+ return (await res.json());
54
+ }
55
+ // -- /api/agent -----------------------------------------------------------
56
+ /** GET /api/agent – verify the bearer token and return agent metadata. */
57
+ async authenticate() {
58
+ return this.request("GET", "/api/agent");
59
+ }
60
+ // -- /api/agent/context ---------------------------------------------------
61
+ /** GET /api/agent/context – fetch the full room context pack. */
62
+ async getContext() {
63
+ return this.request("GET", "/api/agent/context");
64
+ }
65
+ // -- /api/agent/backlog ---------------------------------------------------
66
+ /** GET /api/agent/backlog – list all backlog items in the room. */
67
+ async listBacklog() {
68
+ return this.request("GET", "/api/agent/backlog");
69
+ }
70
+ /** POST /api/agent/backlog – create a new backlog item. */
71
+ async createBacklogItem(payload) {
72
+ return this.request("POST", "/api/agent/backlog", payload);
73
+ }
74
+ /** POST /api/agent/backlog/:id/claim – claim a backlog item. */
75
+ async claimBacklogItem(id) {
76
+ return this.request("POST", `/api/agent/backlog/${encodeURIComponent(id)}/claim`);
77
+ }
78
+ /** DELETE /api/agent/backlog/:id/claim – release a backlog claim. */
79
+ async releaseBacklogClaim(id) {
80
+ return this.request("DELETE", `/api/agent/backlog/${encodeURIComponent(id)}/claim`);
81
+ }
82
+ // -- /api/agent/investigations --------------------------------------------
83
+ /** POST /api/agent/investigations – register a new investigation. */
84
+ async createInvestigation(payload) {
85
+ return this.request("POST", "/api/agent/investigations", payload);
86
+ }
87
+ /** PATCH /api/agent/investigations/:id – heartbeat an investigation. */
88
+ async heartbeatInvestigation(id) {
89
+ return this.request("PATCH", `/api/agent/investigations/${encodeURIComponent(id)}`, { action: "heartbeat" });
90
+ }
91
+ /** PATCH /api/agent/investigations/:id – complete an investigation. */
92
+ async completeInvestigation(id) {
93
+ return this.request("PATCH", `/api/agent/investigations/${encodeURIComponent(id)}`, { action: "complete" });
94
+ }
95
+ /** DELETE /api/agent/investigations/:id – abandon an investigation. */
96
+ async abandonInvestigation(id) {
97
+ return this.request("DELETE", `/api/agent/investigations/${encodeURIComponent(id)}`);
98
+ }
99
+ // -- /api/agent/sync ------------------------------------------------------
100
+ /** POST /api/agent/sync – request a room repo sync. */
101
+ async requestSync() {
102
+ return this.request("POST", "/api/agent/sync");
103
+ }
104
+ // -- /api/agent/threads (deferred) ----------------------------------------
105
+ // deferred: discussions disabled in MVP
106
+ async listThreads(..._args) {
107
+ throw new Error("Discussions are disabled in the MVP.");
108
+ }
109
+ // deferred: discussions disabled in MVP
110
+ async createThread(..._args) {
111
+ throw new Error("Discussions are disabled in the MVP.");
112
+ }
113
+ // deferred: discussions disabled in MVP
114
+ async listThreadMessages(..._args) {
115
+ throw new Error("Discussions are disabled in the MVP.");
116
+ }
117
+ // deferred: discussions disabled in MVP
118
+ async postThreadMessage(..._args) {
119
+ throw new Error("Discussions are disabled in the MVP.");
120
+ }
121
+ }
122
+ //# sourceMappingURL=substrate-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"substrate-client.js","sourceRoot":"","sources":["../src/substrate-client.ts"],"names":[],"mappings":"AAaA,8EAA8E;AAC9E,QAAQ;AACR,8EAA8E;AAE9E,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,UAAU,CAAS;IACnB,SAAS,CAAS;IAE3B,YAAY,UAAkB,EAAE,SAAiB,EAAE,OAAe;QAChE,KAAK,CAAC,OAAO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,CAAC;IAED,wCAAwC;IACxC,KAAK,CAAC,iBAAiB,CAAC,GAAG,KAAgB;QACzC,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type SubstrateClient } from "../substrate-client.js";
3
+ export declare function register(server: McpServer, client: SubstrateClient): void;
4
+ //# sourceMappingURL=backlog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backlog.d.ts","sourceRoot":"","sources":["../../src/tools/backlog.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEjF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAoKzE"}
@@ -0,0 +1,146 @@
1
+ import { z } from "zod";
2
+ import { SubstrateApiError } from "../substrate-client.js";
3
+ export function register(server, client) {
4
+ // -- list_backlog -----------------------------------------------------------
5
+ server.tool("list_backlog", "List all backlog items in the room. Returns an array of backlog items " +
6
+ "with their id, title, description, type, priority, status, claim state, " +
7
+ "and metadata. Use this to see what work is queued, in progress, or done.", async () => {
8
+ try {
9
+ const response = await client.listBacklog();
10
+ return {
11
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
12
+ };
13
+ }
14
+ catch (error) {
15
+ if (error instanceof SubstrateApiError) {
16
+ return {
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
21
+ },
22
+ ],
23
+ isError: true,
24
+ };
25
+ }
26
+ throw error;
27
+ }
28
+ });
29
+ // -- create_backlog_item ----------------------------------------------------
30
+ server.tool("create_backlog_item", "Create a new backlog item in the room. Backlog items represent units of " +
31
+ "work such as hypothesis tests, replications, critiques, syntheses, " +
32
+ "reviews, meta-analyses, or other tasks. Returns the created item.", {
33
+ title: z.string().describe("Title of the backlog item (required)."),
34
+ description: z
35
+ .string()
36
+ .optional()
37
+ .describe("Optional longer description of the work to be done."),
38
+ type: z
39
+ .enum([
40
+ "hypothesis_test",
41
+ "replication",
42
+ "critique",
43
+ "synthesis",
44
+ "review",
45
+ "meta_analysis",
46
+ "other",
47
+ ])
48
+ .describe("The kind of work this item represents."),
49
+ priority: z
50
+ .enum(["low", "medium", "high"])
51
+ .default("medium")
52
+ .describe("Priority level. Defaults to 'medium' if omitted."),
53
+ skillTag: z
54
+ .string()
55
+ .optional()
56
+ .describe("Optional skill tag to route the item to a specific agent capability."),
57
+ }, async (args) => {
58
+ try {
59
+ const response = await client.createBacklogItem({
60
+ title: args.title,
61
+ description: args.description ?? null,
62
+ type: args.type,
63
+ priority: args.priority,
64
+ skillTag: args.skillTag ?? null,
65
+ });
66
+ return {
67
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
68
+ };
69
+ }
70
+ catch (error) {
71
+ if (error instanceof SubstrateApiError) {
72
+ return {
73
+ content: [
74
+ {
75
+ type: "text",
76
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
77
+ },
78
+ ],
79
+ isError: true,
80
+ };
81
+ }
82
+ throw error;
83
+ }
84
+ });
85
+ // -- claim_backlog_item -----------------------------------------------------
86
+ server.tool("claim_backlog_item", "Claim a backlog item, signalling that you intend to work on it. " +
87
+ "Claiming prevents other agents from picking up the same item. " +
88
+ "Returns the updated backlog item with claim metadata. " +
89
+ "If the item is already claimed by another agent, the API returns an error.", {
90
+ backlog_item_id: z
91
+ .string()
92
+ .describe("The ID of the backlog item to claim."),
93
+ }, async (args) => {
94
+ try {
95
+ const response = await client.claimBacklogItem(args.backlog_item_id);
96
+ return {
97
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
98
+ };
99
+ }
100
+ catch (error) {
101
+ if (error instanceof SubstrateApiError) {
102
+ return {
103
+ content: [
104
+ {
105
+ type: "text",
106
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
107
+ },
108
+ ],
109
+ isError: true,
110
+ };
111
+ }
112
+ throw error;
113
+ }
114
+ });
115
+ // -- release_backlog_claim --------------------------------------------------
116
+ server.tool("release_backlog_claim", "Release your claim on a backlog item, making it available for other " +
117
+ "agents to pick up. Use this when you decide not to work on an item " +
118
+ "you previously claimed, or when you need to hand it off. " +
119
+ "Returns the updated backlog item with the claim removed.", {
120
+ backlog_item_id: z
121
+ .string()
122
+ .describe("The ID of the backlog item whose claim to release."),
123
+ }, async (args) => {
124
+ try {
125
+ const response = await client.releaseBacklogClaim(args.backlog_item_id);
126
+ return {
127
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
128
+ };
129
+ }
130
+ catch (error) {
131
+ if (error instanceof SubstrateApiError) {
132
+ return {
133
+ content: [
134
+ {
135
+ type: "text",
136
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
137
+ },
138
+ ],
139
+ isError: true,
140
+ };
141
+ }
142
+ throw error;
143
+ }
144
+ });
145
+ }
146
+ //# sourceMappingURL=backlog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backlog.js","sourceRoot":"","sources":["../../src/tools/backlog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAwB,MAAM,wBAAwB,CAAC;AAEjF,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,MAAuB;IACjE,8EAA8E;IAE9E,MAAM,CAAC,IAAI,CACT,cAAc,EACd,wEAAwE;QACtE,0EAA0E;QAC1E,0EAA0E,EAC5E,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,CAAC;YAC5C,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI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CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,11 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type SubstrateClient } from "../substrate-client.js";
3
+ /**
4
+ * Registers the `get_context` tool on the given MCP server.
5
+ *
6
+ * Pattern: each tool file exports a single `register` function that receives
7
+ * the MCP server and a shared SubstrateClient instance. This keeps tool
8
+ * definitions self-contained and the wiring in index.ts minimal.
9
+ */
10
+ export declare function register(server: McpServer, client: SubstrateClient): void;
11
+ //# sourceMappingURL=get-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-context.d.ts","sourceRoot":"","sources":["../../src/tools/get-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEjF;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CA4BzE"}
@@ -0,0 +1,35 @@
1
+ import { SubstrateApiError } from "../substrate-client.js";
2
+ /**
3
+ * Registers the `get_context` tool on the given MCP server.
4
+ *
5
+ * Pattern: each tool file exports a single `register` function that receives
6
+ * the MCP server and a shared SubstrateClient instance. This keeps tool
7
+ * definitions self-contained and the wiring in index.ts minimal.
8
+ */
9
+ export function register(server, client) {
10
+ server.tool("get_context", "Fetch the full agent context pack for the room. Returns room metadata, " +
11
+ "work queue (active, queued, stale, recent outcomes), recent nanopubs, " +
12
+ "discussion threads, repo sync state, and guidance. Takes no parameters.", async () => {
13
+ try {
14
+ const response = await client.getContext();
15
+ return {
16
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
17
+ };
18
+ }
19
+ catch (error) {
20
+ if (error instanceof SubstrateApiError) {
21
+ return {
22
+ content: [
23
+ {
24
+ type: "text",
25
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
26
+ },
27
+ ],
28
+ isError: true,
29
+ };
30
+ }
31
+ throw error;
32
+ }
33
+ });
34
+ }
35
+ //# sourceMappingURL=get-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-context.js","sourceRoot":"","sources":["../../src/tools/get-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,wBAAwB,CAAC;AAEjF;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,MAAuB;IACjE,MAAM,CAAC,IAAI,CACT,aAAa,EACb,yEAAyE;QACvE,wEAAwE;QACxE,yEAAyE,EAC3E,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;YAC3C,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;aAC9E,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,KAAK,YAAY,iBAAiB,EAAE,CAAC;gBACvC,OAAO;oBACL,OAAO,EAAE;wBACP;4BACE,IAAI,EAAE,MAAe;4BACrB,IAAI,EAAE,SAAS,KAAK,CAAC,UAAU,KAAK,KAAK,CAAC,SAAS,MAAM,KAAK,CAAC,OAAO,EAAE;yBACzE;qBACF;oBACD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YACD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type SubstrateClient } from "../substrate-client.js";
3
+ export declare function register(server: McpServer, client: SubstrateClient): void;
4
+ //# sourceMappingURL=investigations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"investigations.d.ts","sourceRoot":"","sources":["../../src/tools/investigations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEjF,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAuKzE"}
@@ -0,0 +1,148 @@
1
+ import { z } from "zod";
2
+ import { SubstrateApiError } from "../substrate-client.js";
3
+ export function register(server, client) {
4
+ // -- create_investigation ---------------------------------------------------
5
+ server.tool("create_investigation", "Register a new investigation in the room. An investigation represents an " +
6
+ "active research effort on a dedicated branch. The lifecycle is: " +
7
+ "create → heartbeat periodically → complete or abandon. " +
8
+ "After creation you MUST send periodic heartbeats to prevent the platform " +
9
+ "from marking the investigation as stale. Optionally link to a claimed " +
10
+ "backlog item to track which work item the investigation addresses.", {
11
+ title: z.string().describe("Title of the investigation (required)."),
12
+ branch_name: z
13
+ .string()
14
+ .describe("Git branch name for this investigation (required)."),
15
+ hypothesis_statement: z
16
+ .string()
17
+ .optional()
18
+ .describe("Optional hypothesis statement being tested."),
19
+ objective: z
20
+ .string()
21
+ .optional()
22
+ .describe("Optional objective describing what the investigation aims to achieve."),
23
+ backlog_item_id: z
24
+ .string()
25
+ .optional()
26
+ .describe("Optional ID of a claimed backlog item this investigation addresses."),
27
+ }, async (args) => {
28
+ try {
29
+ const response = await client.createInvestigation({
30
+ title: args.title,
31
+ branchName: args.branch_name,
32
+ hypothesisStatement: args.hypothesis_statement ?? null,
33
+ objective: args.objective ?? null,
34
+ backlogItemId: args.backlog_item_id ?? null,
35
+ });
36
+ return {
37
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
38
+ };
39
+ }
40
+ catch (error) {
41
+ if (error instanceof SubstrateApiError) {
42
+ return {
43
+ content: [
44
+ {
45
+ type: "text",
46
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
47
+ },
48
+ ],
49
+ isError: true,
50
+ };
51
+ }
52
+ throw error;
53
+ }
54
+ });
55
+ // -- heartbeat_investigation ------------------------------------------------
56
+ server.tool("heartbeat_investigation", "Send a heartbeat for an active investigation to keep its lease alive. " +
57
+ "Investigations that do not receive heartbeats within the platform's " +
58
+ "configured timeout will be marked as stale. Call this periodically " +
59
+ "(e.g. every few minutes) while actively working on an investigation. " +
60
+ "Returns the updated investigation with refreshed lease expiry.", {
61
+ investigation_id: z
62
+ .string()
63
+ .describe("The ID of the investigation to heartbeat."),
64
+ }, async (args) => {
65
+ try {
66
+ const response = await client.heartbeatInvestigation(args.investigation_id);
67
+ return {
68
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
69
+ };
70
+ }
71
+ catch (error) {
72
+ if (error instanceof SubstrateApiError) {
73
+ return {
74
+ content: [
75
+ {
76
+ type: "text",
77
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
78
+ },
79
+ ],
80
+ isError: true,
81
+ };
82
+ }
83
+ throw error;
84
+ }
85
+ });
86
+ // -- complete_investigation -------------------------------------------------
87
+ server.tool("complete_investigation", "Mark an investigation as complete. This signals that the research effort " +
88
+ "has finished successfully and the branch is ready for review. " +
89
+ "The investigation's lease is released and its status moves to 'completed'. " +
90
+ "Returns the updated investigation record.", {
91
+ investigation_id: z
92
+ .string()
93
+ .describe("The ID of the investigation to complete."),
94
+ }, async (args) => {
95
+ try {
96
+ const response = await client.completeInvestigation(args.investigation_id);
97
+ return {
98
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
99
+ };
100
+ }
101
+ catch (error) {
102
+ if (error instanceof SubstrateApiError) {
103
+ return {
104
+ content: [
105
+ {
106
+ type: "text",
107
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
108
+ },
109
+ ],
110
+ isError: true,
111
+ };
112
+ }
113
+ throw error;
114
+ }
115
+ });
116
+ // -- abandon_investigation --------------------------------------------------
117
+ server.tool("abandon_investigation", "Abandon an investigation and release the branch. Use this when the " +
118
+ "research effort is no longer viable or you need to give up the branch. " +
119
+ "The investigation's lease is released and its status moves to 'abandoned'. " +
120
+ "This frees the branch name for reuse by another investigation. " +
121
+ "Returns the updated investigation record.", {
122
+ investigation_id: z
123
+ .string()
124
+ .describe("The ID of the investigation to abandon."),
125
+ }, async (args) => {
126
+ try {
127
+ const response = await client.abandonInvestigation(args.investigation_id);
128
+ return {
129
+ content: [{ type: "text", text: JSON.stringify(response, null, 2) }],
130
+ };
131
+ }
132
+ catch (error) {
133
+ if (error instanceof SubstrateApiError) {
134
+ return {
135
+ content: [
136
+ {
137
+ type: "text",
138
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
139
+ },
140
+ ],
141
+ isError: true,
142
+ };
143
+ }
144
+ throw error;
145
+ }
146
+ });
147
+ }
148
+ //# sourceMappingURL=investigations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"investigations.js","sourceRoot":"","sources":["../../src/tools/investigations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,iBAAiB,EAAwB,MAAM,wBAAwB,CAAC;AAEjF,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,MAAuB;IACjE,8EAA8E;IAE9E,MAAM,CAAC,IAAI,CACT,sBAAsB,EACtB,2EAA2E;QACzE,kEAAkE;QAClE,yDAAyD;QACzD,2EAA2E;QAC3E,wEAAwE;QACxE,oEAAoE,EACtE;QACE,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,wCAAwC,CAAC;QACpE,WAAW,EAAE,CAAC;aACX,MAAM,EAAE;aACR,QAAQ,CAAC,oDAAoD,CAAC;QACjE,oBAAoB,EAAE,CAAC;aACpB,MAAM,EAAE;aACR,QAAQ,EAAE;aACV,QAAQ,CAAC,6CAA6C,CAAC;QAC1D,SAAS,EAAE,CAAC;aACT,MAAM,E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@@
1
+ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { type SubstrateClient } from "../substrate-client.js";
3
+ /**
4
+ * Registers the `list_nanopubs` tool on the given MCP server.
5
+ *
6
+ * Returns recent nanopubs from the room context pack. The agent API does not
7
+ * currently expose a dedicated nanopub-read endpoint, so this tool extracts
8
+ * the `nanopubs.recent` section from the full context pack (up to 8 items,
9
+ * sorted by import date descending).
10
+ */
11
+ export declare function register(server: McpServer, client: SubstrateClient): void;
12
+ //# sourceMappingURL=nanopubs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nanopubs.d.ts","sourceRoot":"","sources":["../../src/tools/nanopubs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,EAAqB,KAAK,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEjF;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,eAAe,GAAG,IAAI,CAiDzE"}
@@ -0,0 +1,56 @@
1
+ import { SubstrateApiError } from "../substrate-client.js";
2
+ /**
3
+ * Registers the `list_nanopubs` tool on the given MCP server.
4
+ *
5
+ * Returns recent nanopubs from the room context pack. The agent API does not
6
+ * currently expose a dedicated nanopub-read endpoint, so this tool extracts
7
+ * the `nanopubs.recent` section from the full context pack (up to 8 items,
8
+ * sorted by import date descending).
9
+ */
10
+ export function register(server, client) {
11
+ server.tool("list_nanopubs", "List recent nanopubs published in the room. Returns up to 8 nanopubs " +
12
+ "(most-recently imported first) extracted from the agent context pack. " +
13
+ "Each nanopub includes: id, assertionKind, assertionTitle, branchName, " +
14
+ "commitSha, repoPath, evidenceSummary, externalNanopubId, importedAt, " +
15
+ "verifiedActorCount, and optional links to an investigation or backlog item. " +
16
+ "Nanopubs are JSON research documents committed to `.substrate/nanopubs/` " +
17
+ "in the connected GitHub repo and imported during sync. They follow a " +
18
+ "structured envelope (assertion, provenance, publicationInfo, substrate links) " +
19
+ "at schema version 0. " +
20
+ "Note: this returns summary data from the context pack, not the full " +
21
+ "nanopub document. For full nanopub content, read the file directly from " +
22
+ "the repo at the indicated repoPath and commitSha. " +
23
+ "Takes no parameters.", async () => {
24
+ try {
25
+ const response = await client.getContext();
26
+ const nanopubs = response.contextPack.nanopubs.recent;
27
+ const total = response.contextPack.summary.nanopubs.totalCount;
28
+ const result = {
29
+ nanopubs,
30
+ total,
31
+ note: nanopubs.length < total
32
+ ? `Showing ${nanopubs.length} of ${total} total nanopubs (most recent). ` +
33
+ "For full nanopub content, read the file from the repo at the indicated repoPath."
34
+ : `All ${total} nanopub(s) in the room.`,
35
+ };
36
+ return {
37
+ content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
38
+ };
39
+ }
40
+ catch (error) {
41
+ if (error instanceof SubstrateApiError) {
42
+ return {
43
+ content: [
44
+ {
45
+ type: "text",
46
+ text: `Error ${error.statusCode} (${error.errorCode}): ${error.message}`,
47
+ },
48
+ ],
49
+ isError: true,
50
+ };
51
+ }
52
+ throw error;
53
+ }
54
+ });
55
+ }
56
+ //# sourceMappingURL=nanopubs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nanopubs.js","sourceRoot":"","sources":["../../src/tools/nanopubs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAwB,MAAM,wBAAwB,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAiB,EAAE,MAAuB;IACjE,MAAM,CAAC,IAAI,CACT,eAAe,EACf,uEAAuE;QACrE,wEAAwE;QACxE,wEAAwE;QACxE,uEAAuE;QACvE,8EAA8E;QAC9E,2EAA2E;QAC3E,uEAAuE;QACvE,gFAAgF;QAChF,uBAAuB;QACvB,sEAAsE;QACtE,0EAA0E;QAC1E,oDAAoD;QACpD,sBAAsB,EACxB,KAAK,IAAI,EAAE;QACT,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,M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