@nexusm/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 +21 -0
- package/README.md +13 -0
- package/RUNBOOK.md +190 -0
- package/dist/auth.d.ts +49 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +62 -0
- package/dist/auth.js.map +1 -0
- package/dist/errors.d.ts +211 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +245 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +146 -0
- package/dist/index.js.map +1 -0
- package/dist/metrics.d.ts +146 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +245 -0
- package/dist/metrics.js.map +1 -0
- package/dist/tools/context.d.ts +48 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/context.js +229 -0
- package/dist/tools/context.js.map +1 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +19 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/memory_create.d.ts +37 -0
- package/dist/tools/memory_create.d.ts.map +1 -0
- package/dist/tools/memory_create.js +242 -0
- package/dist/tools/memory_create.js.map +1 -0
- package/dist/tools/memory_feedback.d.ts +44 -0
- package/dist/tools/memory_feedback.d.ts.map +1 -0
- package/dist/tools/memory_feedback.js +259 -0
- package/dist/tools/memory_feedback.js.map +1 -0
- package/dist/tools/memory_search.d.ts +44 -0
- package/dist/tools/memory_search.d.ts.map +1 -0
- package/dist/tools/memory_search.js +160 -0
- package/dist/tools/memory_search.js.map +1 -0
- package/dist/tools/types.d.ts +36 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +29 -0
- package/dist/tools/types.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool: nexus.memory_search (US-037 TASK-010, Wave 2).
|
|
3
|
+
*
|
|
4
|
+
* Targeted memory search over the Nexus REST API via `@nexusm/sdk`.
|
|
5
|
+
*
|
|
6
|
+
* Schema is locked in proposal §"R2 工具 Schema 锁定" Tool 2 (+ R2.1) and
|
|
7
|
+
* MUST be preserved verbatim — the parity check
|
|
8
|
+
* `tests/unit/schema_sync.test.ts` will fail loudly if drift is introduced.
|
|
9
|
+
*
|
|
10
|
+
* Design decisions resolved during implementation:
|
|
11
|
+
*
|
|
12
|
+
* - `mode` defaults to `'hybrid'` per proposal §M-11 / §A2-D-1
|
|
13
|
+
* (no pure-keyword mode in Phase 1; hybrid handles CJK via the
|
|
14
|
+
* backend's trigram `word_similarity` fallback documented in
|
|
15
|
+
* `repositories/__init__.py::search_by_trigram`).
|
|
16
|
+
*
|
|
17
|
+
* - Enum violations on `mode` are surfaced as a JSON-RPC
|
|
18
|
+
* `InvalidParams` protocol error (proposal §M-3 mapping table:
|
|
19
|
+
* 422 → InvalidParams). The MCP core dispatcher in `src/index.ts`
|
|
20
|
+
* does NOT validate input against the declared inputSchema — that
|
|
21
|
+
* responsibility lives in this handler.
|
|
22
|
+
*
|
|
23
|
+
* - `score_threshold` is forwarded to the SDK body verbatim. The
|
|
24
|
+
* backend `/memories/search` endpoint accepts it under that exact
|
|
25
|
+
* name (the SDK's older `threshold` field is a historical alias
|
|
26
|
+
* that the backend also accepts; the locked MCP schema uses the
|
|
27
|
+
* new name, so we forward the new name).
|
|
28
|
+
*
|
|
29
|
+
* - `NexusClient` is lazily constructed on first handler invocation
|
|
30
|
+
* from `loadAuthConfig()` and cached for subsequent calls. This
|
|
31
|
+
* keeps construction cost off the `tools/list` hot path and lets
|
|
32
|
+
* tests inject a mock via `vi.mock('@nexusm/sdk', ...)` before the
|
|
33
|
+
* first call.
|
|
34
|
+
*/
|
|
35
|
+
import { NexusClient } from '@nexusm/sdk';
|
|
36
|
+
import { loadAuthConfig } from '../auth.js';
|
|
37
|
+
import { McpErrorCode, NexusError, isAxiosLikeError, mapHttpStatusToMcpError } from '../errors.js';
|
|
38
|
+
const NAME = 'nexus.memory_search';
|
|
39
|
+
const ALLOWED_MODES = ['semantic', 'hybrid'];
|
|
40
|
+
const DEFAULT_MODE = 'hybrid';
|
|
41
|
+
/** Lazily-instantiated SDK client. Reset by `__resetClientForTesting`. */
|
|
42
|
+
let clientSingleton = null;
|
|
43
|
+
function getClient() {
|
|
44
|
+
if (clientSingleton === null) {
|
|
45
|
+
const auth = loadAuthConfig();
|
|
46
|
+
clientSingleton = new NexusClient({
|
|
47
|
+
apiKey: auth.apiToken,
|
|
48
|
+
baseUrl: auth.apiUrl,
|
|
49
|
+
tenantId: auth.tenantId,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return clientSingleton;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Test-only seam: reset the cached client so a `vi.mock` of `@nexusm/sdk`
|
|
56
|
+
* applied between tests can re-construct against the fresh mock.
|
|
57
|
+
*
|
|
58
|
+
* @internal
|
|
59
|
+
*/
|
|
60
|
+
export function __resetClientForTesting() {
|
|
61
|
+
clientSingleton = null;
|
|
62
|
+
}
|
|
63
|
+
export const memorySearchTool = {
|
|
64
|
+
name: NAME,
|
|
65
|
+
description: "Targeted semantic search over memories. Use when query has specific keyword/topic and user wants list of memories (no need for conversation/knowledge layers). For Chinese queries, mode='hybrid' falls back to trigram word_similarity.",
|
|
66
|
+
inputSchema: {
|
|
67
|
+
type: 'object',
|
|
68
|
+
properties: {
|
|
69
|
+
user_id: { type: 'string' },
|
|
70
|
+
query: { type: 'string' },
|
|
71
|
+
limit: { type: 'integer', default: 10, minimum: 1, maximum: 50 },
|
|
72
|
+
mode: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
enum: ['semantic', 'hybrid'],
|
|
75
|
+
default: 'hybrid',
|
|
76
|
+
description: 'semantic=dense vector only; hybrid=vector + trigram fallback (recommended for CJK/keyword queries).',
|
|
77
|
+
},
|
|
78
|
+
score_threshold: { type: 'number', default: 0.0, minimum: 0.0, maximum: 1.0 },
|
|
79
|
+
memory_type: {
|
|
80
|
+
type: 'string',
|
|
81
|
+
enum: ['episodic', 'semantic', 'procedural'],
|
|
82
|
+
nullable: true,
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
required: ['user_id', 'query'],
|
|
86
|
+
},
|
|
87
|
+
outputSchema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
memories: { type: 'array', items: { type: 'object' } },
|
|
91
|
+
total: { type: 'integer' },
|
|
92
|
+
},
|
|
93
|
+
required: ['memories', 'total'],
|
|
94
|
+
},
|
|
95
|
+
handler: async (args) => {
|
|
96
|
+
// Required field shape: rely on MCP `required` declaration + SDK Zod
|
|
97
|
+
// for deep validation; here we only enforce the enum constraints that
|
|
98
|
+
// the dispatcher does not check.
|
|
99
|
+
const rawMode = args.mode;
|
|
100
|
+
let mode;
|
|
101
|
+
if (rawMode === undefined) {
|
|
102
|
+
mode = DEFAULT_MODE;
|
|
103
|
+
}
|
|
104
|
+
else if (typeof rawMode === 'string' &&
|
|
105
|
+
ALLOWED_MODES.includes(rawMode)) {
|
|
106
|
+
mode = rawMode;
|
|
107
|
+
}
|
|
108
|
+
else {
|
|
109
|
+
throw new NexusError(`Invalid mode "${String(rawMode)}". Allowed: ${ALLOWED_MODES.join(', ')}.`, McpErrorCode.InvalidParams, 422);
|
|
110
|
+
}
|
|
111
|
+
const body = {
|
|
112
|
+
user_id: String(args.user_id),
|
|
113
|
+
query: String(args.query),
|
|
114
|
+
mode,
|
|
115
|
+
};
|
|
116
|
+
if (args.limit !== undefined)
|
|
117
|
+
body.limit = args.limit;
|
|
118
|
+
if (args.score_threshold !== undefined)
|
|
119
|
+
body.score_threshold = args.score_threshold;
|
|
120
|
+
if (args.memory_type !== undefined && args.memory_type !== null) {
|
|
121
|
+
body.memory_type = args.memory_type;
|
|
122
|
+
}
|
|
123
|
+
const client = getClient();
|
|
124
|
+
// Cast: SDK's `MemorySearch` type predates the `mode`/`score_threshold`
|
|
125
|
+
// additions locked in proposal R2; the SDK Zod schema is permissive
|
|
126
|
+
// (no `.strict()`) so the extra fields pass through to the HTTP body.
|
|
127
|
+
// Wave 2B mid_audit-to-pre_merge fix: wrap SDK call in try/catch +
|
|
128
|
+
// route SDK errors through mapHttpStatusToMcpError (proposal §M-3 mapping),
|
|
129
|
+
// mirroring context.ts pattern. Without this, axios-like 401/403/429
|
|
130
|
+
// would surface as JSON-RPC InternalError (-32603) instead of the
|
|
131
|
+
// semantically-correct Unauthorized/RateLimited codes from TASK-013.
|
|
132
|
+
let result;
|
|
133
|
+
try {
|
|
134
|
+
result = await client.memories.search(body);
|
|
135
|
+
}
|
|
136
|
+
catch (err) {
|
|
137
|
+
if (isAxiosLikeError(err)) {
|
|
138
|
+
const status = err.response?.status ?? null;
|
|
139
|
+
const respBody = err.response?.data ?? null;
|
|
140
|
+
const headers = err.response?.headers;
|
|
141
|
+
throw mapHttpStatusToMcpError(status, respBody, headers);
|
|
142
|
+
}
|
|
143
|
+
throw mapHttpStatusToMcpError(null, null);
|
|
144
|
+
}
|
|
145
|
+
const memories = result.results ?? [];
|
|
146
|
+
return {
|
|
147
|
+
content: [
|
|
148
|
+
{
|
|
149
|
+
type: 'text',
|
|
150
|
+
text: JSON.stringify({ memories, total: memories.length }),
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
structuredContent: {
|
|
154
|
+
memories,
|
|
155
|
+
total: memories.length,
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
};
|
|
160
|
+
//# sourceMappingURL=memory_search.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory_search.js","sourceRoot":"","sources":["../../src/tools/memory_search.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;A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C,OAAO,IAAI,EAAE,CAAC;QACtC,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC;iBAC3D;aACF;YACD,iBAAiB,EAAE;gBACjB,QAAQ;gBACR,KAAK,EAAE,QAAQ,CAAC,MAAM;aACvB;SACF,CAAC;IACJ,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for MCP tool definitions.
|
|
3
|
+
*
|
|
4
|
+
* Each tool exports a {@link ToolDefinition} carrying:
|
|
5
|
+
* - JSON Schema input/output (locked in proposal §"R2 工具 Schema 锁定" + R2.1)
|
|
6
|
+
* - Async handler that returns an MCP {@link CallToolResult}
|
|
7
|
+
*
|
|
8
|
+
* In Wave 1 TASK-003 every handler returns NOT_IMPLEMENTED. Subsequent tasks
|
|
9
|
+
* (TASK-007..010) wire each handler to the nexus-sdk-js client.
|
|
10
|
+
*/
|
|
11
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
12
|
+
/** JSON Schema fragment as embedded in tool definitions. Intentionally loose
|
|
13
|
+
* (`unknown` properties) — the locked schemas use JSON-Schema-draft-07 idioms
|
|
14
|
+
* that TypeScript can't capture without a heavyweight schema library. */
|
|
15
|
+
export type JsonSchemaObject = {
|
|
16
|
+
type: 'object';
|
|
17
|
+
properties: Record<string, unknown>;
|
|
18
|
+
required?: string[];
|
|
19
|
+
additionalProperties?: boolean | Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
export interface ToolDefinition {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
inputSchema: JsonSchemaObject;
|
|
25
|
+
outputSchema: JsonSchemaObject;
|
|
26
|
+
handler: (args: Record<string, unknown>) => Promise<CallToolResult>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Standard NOT_IMPLEMENTED result for Wave 1 scaffold handlers.
|
|
30
|
+
*
|
|
31
|
+
* MCP best practice: tool-level errors are reported via `isError: true` in
|
|
32
|
+
* the result, not as a JSON-RPC protocol error. The LLM can then see the
|
|
33
|
+
* error and self-correct (per CallToolResult spec).
|
|
34
|
+
*/
|
|
35
|
+
export declare function notImplementedResult(toolName: string): CallToolResult;
|
|
36
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEzE;;yEAEyE;AACzE,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,QAAQ,CAAC;IACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,oBAAoB,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,YAAY,EAAE,gBAAgB,CAAC;IAC/B,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACrE;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAUrE"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for MCP tool definitions.
|
|
3
|
+
*
|
|
4
|
+
* Each tool exports a {@link ToolDefinition} carrying:
|
|
5
|
+
* - JSON Schema input/output (locked in proposal §"R2 工具 Schema 锁定" + R2.1)
|
|
6
|
+
* - Async handler that returns an MCP {@link CallToolResult}
|
|
7
|
+
*
|
|
8
|
+
* In Wave 1 TASK-003 every handler returns NOT_IMPLEMENTED. Subsequent tasks
|
|
9
|
+
* (TASK-007..010) wire each handler to the nexus-sdk-js client.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Standard NOT_IMPLEMENTED result for Wave 1 scaffold handlers.
|
|
13
|
+
*
|
|
14
|
+
* MCP best practice: tool-level errors are reported via `isError: true` in
|
|
15
|
+
* the result, not as a JSON-RPC protocol error. The LLM can then see the
|
|
16
|
+
* error and self-correct (per CallToolResult spec).
|
|
17
|
+
*/
|
|
18
|
+
export function notImplementedResult(toolName) {
|
|
19
|
+
return {
|
|
20
|
+
isError: true,
|
|
21
|
+
content: [
|
|
22
|
+
{
|
|
23
|
+
type: 'text',
|
|
24
|
+
text: `NOT_IMPLEMENTED: ${toolName} handler is a Wave 1 scaffold and will be wired to nexus-sdk-js in TASK-007..010.`,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAsBH;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAAC,QAAgB;IACnD,OAAO;QACL,OAAO,EAAE,IAAI;QACb,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,oBAAoB,QAAQ,mFAAmF;aACtH;SACF;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nexusm/mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Nexusm MCP Server — generic MCP server exposing Nexusm core capabilities to MCP clients via stdio + Streamable HTTP transports.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"nexusm-mcp-server": "./dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**",
|
|
13
|
+
"README.md",
|
|
14
|
+
"RUNBOOK.md",
|
|
15
|
+
"LICENSE"
|
|
16
|
+
],
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"engines": {
|
|
21
|
+
"node": ">=18.0.0"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://forgejo.10cg.pub/10CG/nexusm-mcp-server"
|
|
27
|
+
},
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "tsc",
|
|
30
|
+
"test": "vitest run",
|
|
31
|
+
"test:unit": "vitest run --config vitest.unit.config.ts",
|
|
32
|
+
"test:watch": "vitest",
|
|
33
|
+
"test:integration": "vitest run --config vitest.integration.config.ts",
|
|
34
|
+
"lint": "eslint src/ tests/ && prettier --check src/ tests/"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
38
|
+
"@nexusm/sdk": "1.3.0",
|
|
39
|
+
"prom-client": "^15.1.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "^20.0.0",
|
|
43
|
+
"typescript": "^5.4.0",
|
|
44
|
+
"vitest": "^1.6.0",
|
|
45
|
+
"eslint": "^8.57.0",
|
|
46
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
48
|
+
"prettier": "^3.2.0"
|
|
49
|
+
}
|
|
50
|
+
}
|