@nocoo/base-mcp 0.1.0-alpha.1
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/README.md +194 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +6 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/oauth-metadata.d.ts +31 -0
- package/dist/auth/oauth-metadata.d.ts.map +1 -0
- package/dist/auth/oauth-metadata.js +33 -0
- package/dist/auth/oauth-metadata.js.map +1 -0
- package/dist/auth/origin.d.ts +32 -0
- package/dist/auth/origin.d.ts.map +1 -0
- package/dist/auth/origin.js +66 -0
- package/dist/auth/origin.js.map +1 -0
- package/dist/auth/pkce.d.ts +40 -0
- package/dist/auth/pkce.d.ts.map +1 -0
- package/dist/auth/pkce.js +78 -0
- package/dist/auth/pkce.js.map +1 -0
- package/dist/auth/token.d.ts +79 -0
- package/dist/auth/token.d.ts.map +1 -0
- package/dist/auth/token.js +108 -0
- package/dist/auth/token.js.map +1 -0
- package/dist/framework/handlers.d.ts +14 -0
- package/dist/framework/handlers.d.ts.map +1 -0
- package/dist/framework/handlers.js +110 -0
- package/dist/framework/handlers.js.map +1 -0
- package/dist/framework/index.d.ts +7 -0
- package/dist/framework/index.d.ts.map +1 -0
- package/dist/framework/index.js +7 -0
- package/dist/framework/index.js.map +1 -0
- package/dist/framework/projection.d.ts +10 -0
- package/dist/framework/projection.d.ts.map +1 -0
- package/dist/framework/projection.js +21 -0
- package/dist/framework/projection.js.map +1 -0
- package/dist/framework/register.d.ts +16 -0
- package/dist/framework/register.d.ts.map +1 -0
- package/dist/framework/register.js +70 -0
- package/dist/framework/register.js.map +1 -0
- package/dist/framework/resolve.d.ts +39 -0
- package/dist/framework/resolve.d.ts.map +1 -0
- package/dist/framework/resolve.js +46 -0
- package/dist/framework/resolve.js.map +1 -0
- package/dist/framework/response.d.ts +6 -0
- package/dist/framework/response.d.ts.map +1 -0
- package/dist/framework/response.js +17 -0
- package/dist/framework/response.js.map +1 -0
- package/dist/framework/types.d.ts +85 -0
- package/dist/framework/types.d.ts.map +1 -0
- package/dist/framework/types.js +5 -0
- package/dist/framework/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/server/create-server.d.ts +24 -0
- package/dist/server/create-server.d.ts.map +1 -0
- package/dist/server/create-server.js +24 -0
- package/dist/server/create-server.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +3 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/utils.d.ts +55 -0
- package/dist/testing/utils.d.ts.map +1 -0
- package/dist/testing/utils.js +66 -0
- package/dist/testing/utils.js.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/framework/types.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIzC,MAAM,WAAW,gBAAgB;IAC/B,qDAAqD;IACrD,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,6EAA6E;IAC7E,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;CAClC;AAID;;;GAGG;AACH,MAAM,WAAW,aAAa,CAAC,MAAM,GAAG,OAAO;IAC7C,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO;IAC5C,IAAI,EAAE,CAAC,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO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,CAAC;IACb,iDAAiD;IACjD,OAAO,EAAE,MAAM,CAAC;IAChB,yDAAyD;IACzD,MAAM,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,SAAS,EAAE,SAAS,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAChC,uCAAuC;IACvC,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,gCAAgC;IAChC,YAAY,CAAC,EAAE,kBAAkB,CAAC;IAClC,qCAAqC;IACrC,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAC9B,sBAAsB;IACtB,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;CAChC;AAID,MAAM,MAAM,WAAW,CAAC,MAAM,GAAG,OAAO,IAAI,CAC1C,GAAG,EAAE,aAAa,CAAC,MAAM,CAAC,EAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC1B,OAAO,CAAC,cAAc,CAAC,CAAC;AAE7B,MAAM,WAAW,gBAAgB,CAAC,MAAM,GAAG,OAAO;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC;IAChD,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/framework/types.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,iDAAiD;AACjD,8EAA8E"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,KAAK,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAGlF,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,eAAe;AACf,OAAO,EAAE,eAAe,EAAwB,MAAM,2BAA2B,CAAC;AAElF,uBAAuB;AACvB,cAAc,sBAAsB,CAAC;AACrC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
export interface McpServerConfig {
|
|
3
|
+
/** Server name (e.g., "noheir") */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Server version (e.g., "3.0.0") */
|
|
6
|
+
version: string;
|
|
7
|
+
/** Server capabilities (optional, sensible defaults provided) */
|
|
8
|
+
capabilities?: {
|
|
9
|
+
tools?: boolean;
|
|
10
|
+
resources?: boolean;
|
|
11
|
+
prompts?: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create an MCP Server instance with the given configuration.
|
|
16
|
+
*
|
|
17
|
+
* This is a thin wrapper around the SDK's McpServer that provides
|
|
18
|
+
* sensible defaults for the base-mcp framework.
|
|
19
|
+
*
|
|
20
|
+
* @param config - Server configuration
|
|
21
|
+
* @returns Configured McpServer instance
|
|
22
|
+
*/
|
|
23
|
+
export declare function createMcpServer(config: McpServerConfig): McpServer;
|
|
24
|
+
//# sourceMappingURL=create-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-server.d.ts","sourceRoot":"","sources":["../../src/server/create-server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,MAAM,WAAW,eAAe;IAC9B,mCAAmC;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,iEAAiE;IACjE,YAAY,CAAC,EAAE;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;QAChB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;CACH;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,eAAe,GAAG,SAAS,CAclE"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// MCP Server Factory
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
/**
|
|
6
|
+
* Create an MCP Server instance with the given configuration.
|
|
7
|
+
*
|
|
8
|
+
* This is a thin wrapper around the SDK's McpServer that provides
|
|
9
|
+
* sensible defaults for the base-mcp framework.
|
|
10
|
+
*
|
|
11
|
+
* @param config - Server configuration
|
|
12
|
+
* @returns Configured McpServer instance
|
|
13
|
+
*/
|
|
14
|
+
export function createMcpServer(config) {
|
|
15
|
+
const { name, version, capabilities = {} } = config;
|
|
16
|
+
// Default capabilities: tools enabled
|
|
17
|
+
const serverCapabilities = {
|
|
18
|
+
tools: capabilities.tools !== false ? {} : undefined,
|
|
19
|
+
resources: capabilities.resources ? {} : undefined,
|
|
20
|
+
prompts: capabilities.prompts ? {} : undefined,
|
|
21
|
+
};
|
|
22
|
+
return new McpServer({ name, version }, { capabilities: serverCapabilities });
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=create-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-server.js","sourceRoot":"","sources":["../../src/server/create-server.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,qBAAqB;AACrB,8EAA8E;AAE9E,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAepE;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAAC,MAAuB;IACrD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,GAAG,EAAE,EAAE,GAAG,MAAM,CAAC;IAEpD,sCAAsC;IACtC,MAAM,kBAAkB,GAAG;QACzB,KAAK,EAAE,YAAY,CAAC,KAAK,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;QACpD,SAAS,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;QAClD,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS;KAC/C,CAAC;IAEF,OAAO,IAAI,SAAS,CAClB,EAAE,IAAI,EAAE,OAAO,EAAE,EACjB,EAAE,YAAY,EAAE,kBAAkB,EAAE,CACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,qBAAqB,GAC3B,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,kBAAkB;AAClB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,WAAW,EACX,mBAAmB,EACnB,oBAAoB,GAErB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { EntityContext } from "../framework/types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Create a mock EntityContext for testing.
|
|
5
|
+
*
|
|
6
|
+
* @param repos - The repos object to inject
|
|
7
|
+
* @returns EntityContext with the given repos
|
|
8
|
+
*/
|
|
9
|
+
export declare function createMockContext<TRepos>(repos: TRepos): EntityContext<TRepos>;
|
|
10
|
+
/**
|
|
11
|
+
* Parse the JSON content from a CallToolResult.
|
|
12
|
+
*
|
|
13
|
+
* @param result - The tool result to parse
|
|
14
|
+
* @returns Parsed JSON data, or null if not parseable
|
|
15
|
+
*/
|
|
16
|
+
export declare function parseToolResult(result: CallToolResult): unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Assert that a tool result is an error.
|
|
19
|
+
*
|
|
20
|
+
* @param result - The tool result to check
|
|
21
|
+
* @returns True if the result is an error
|
|
22
|
+
*/
|
|
23
|
+
export declare function isToolError(result: CallToolResult): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Get the error message from a tool result.
|
|
26
|
+
*
|
|
27
|
+
* @param result - The tool result
|
|
28
|
+
* @returns The error message, or null if not an error
|
|
29
|
+
*/
|
|
30
|
+
export declare function getToolErrorMessage(result: CallToolResult): string | null;
|
|
31
|
+
/**
|
|
32
|
+
* Create a mock token store for testing validateMcpToken.
|
|
33
|
+
*/
|
|
34
|
+
export interface MockTokenStoreOptions {
|
|
35
|
+
token?: {
|
|
36
|
+
id: string;
|
|
37
|
+
user_id: string;
|
|
38
|
+
client_id: string;
|
|
39
|
+
scope: string;
|
|
40
|
+
revoked?: boolean;
|
|
41
|
+
expires_at?: string | null;
|
|
42
|
+
} | null;
|
|
43
|
+
}
|
|
44
|
+
export declare function createMockTokenStore(options?: MockTokenStoreOptions): {
|
|
45
|
+
findByHash: () => Promise<{
|
|
46
|
+
revoked: boolean;
|
|
47
|
+
expires_at: string | null;
|
|
48
|
+
id: string;
|
|
49
|
+
user_id: string;
|
|
50
|
+
client_id: string;
|
|
51
|
+
scope: string;
|
|
52
|
+
} | null>;
|
|
53
|
+
updateLastUsed: () => Promise<void>;
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/testing/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAE9E;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAQ/D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAE3D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAKzE;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE;QACN,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAC5B,GAAG,IAAI,CAAC;CACV;AAED,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B;;;;YAThE,MAAM;iBACD,MAAM;mBACJ,MAAM;eACV,MAAM;;;EAmBhB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Testing Utilities for MCP Framework
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
/**
|
|
5
|
+
* Create a mock EntityContext for testing.
|
|
6
|
+
*
|
|
7
|
+
* @param repos - The repos object to inject
|
|
8
|
+
* @returns EntityContext with the given repos
|
|
9
|
+
*/
|
|
10
|
+
export function createMockContext(repos) {
|
|
11
|
+
return { repos };
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Parse the JSON content from a CallToolResult.
|
|
15
|
+
*
|
|
16
|
+
* @param result - The tool result to parse
|
|
17
|
+
* @returns Parsed JSON data, or null if not parseable
|
|
18
|
+
*/
|
|
19
|
+
export function parseToolResult(result) {
|
|
20
|
+
const textContent = result.content.find((c) => c.type === "text");
|
|
21
|
+
if (!textContent || textContent.type !== "text")
|
|
22
|
+
return null;
|
|
23
|
+
try {
|
|
24
|
+
return JSON.parse(textContent.text);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return textContent.text;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Assert that a tool result is an error.
|
|
32
|
+
*
|
|
33
|
+
* @param result - The tool result to check
|
|
34
|
+
* @returns True if the result is an error
|
|
35
|
+
*/
|
|
36
|
+
export function isToolError(result) {
|
|
37
|
+
return result.isError === true;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the error message from a tool result.
|
|
41
|
+
*
|
|
42
|
+
* @param result - The tool result
|
|
43
|
+
* @returns The error message, or null if not an error
|
|
44
|
+
*/
|
|
45
|
+
export function getToolErrorMessage(result) {
|
|
46
|
+
if (!result.isError)
|
|
47
|
+
return null;
|
|
48
|
+
const textContent = result.content.find((c) => c.type === "text");
|
|
49
|
+
if (!textContent || textContent.type !== "text")
|
|
50
|
+
return null;
|
|
51
|
+
return textContent.text;
|
|
52
|
+
}
|
|
53
|
+
export function createMockTokenStore(options = {}) {
|
|
54
|
+
const { token = null } = options;
|
|
55
|
+
return {
|
|
56
|
+
findByHash: async () => token
|
|
57
|
+
? {
|
|
58
|
+
...token,
|
|
59
|
+
revoked: token.revoked ?? false,
|
|
60
|
+
expires_at: token.expires_at ?? null,
|
|
61
|
+
}
|
|
62
|
+
: null,
|
|
63
|
+
updateLastUsed: async () => { },
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRo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jC,OAAO;QACL,UAAU,EAAE,KAAK,IAAI,EAAE,CACrB,KAAK;YACH,CAAC,CAAC;gBACE,GAAG,KAAK;gBACR,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,KAAK;gBAC/B,UAAU,EAAE,KAAK,CAAC,UAAU,IAAI,IAAI;aACrC;YACH,CAAC,CAAC,IAAI;QACV,cAAc,EAAE,KAAK,IAAI,EAAE,GAAE,CAAC;KAC/B,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nocoo/base-mcp",
|
|
3
|
+
"version": "0.1.0-alpha.1",
|
|
4
|
+
"description": "MCP Server development framework with OAuth 2.1, Entity-Driven CRUD, and Streamable HTTP transport",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./auth": {
|
|
15
|
+
"types": "./dist/auth/index.d.ts",
|
|
16
|
+
"import": "./dist/auth/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./framework": {
|
|
19
|
+
"types": "./dist/framework/index.d.ts",
|
|
20
|
+
"import": "./dist/framework/index.js"
|
|
21
|
+
},
|
|
22
|
+
"./testing": {
|
|
23
|
+
"types": "./dist/testing/index.d.ts",
|
|
24
|
+
"import": "./dist/testing/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist",
|
|
29
|
+
"README.md"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"test:coverage": "vitest run --coverage",
|
|
36
|
+
"lint": "eslint src",
|
|
37
|
+
"typecheck": "tsc --noEmit",
|
|
38
|
+
"prepublishOnly": "pnpm build"
|
|
39
|
+
},
|
|
40
|
+
"keywords": [
|
|
41
|
+
"mcp",
|
|
42
|
+
"model-context-protocol",
|
|
43
|
+
"oauth",
|
|
44
|
+
"crud",
|
|
45
|
+
"framework"
|
|
46
|
+
],
|
|
47
|
+
"author": "nocoo",
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"repository": {
|
|
50
|
+
"type": "git",
|
|
51
|
+
"url": "https://github.com/nocoo/base-mcp.git"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=18.0.0"
|
|
55
|
+
},
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
58
|
+
"zod": "^3.0.0"
|
|
59
|
+
},
|
|
60
|
+
"devDependencies": {
|
|
61
|
+
"@types/node": "^22.0.0",
|
|
62
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
63
|
+
"typescript": "^5.7.0",
|
|
64
|
+
"vitest": "^3.0.0",
|
|
65
|
+
"@vitest/coverage-v8": "^3.0.0",
|
|
66
|
+
"zod": "^3.24.0",
|
|
67
|
+
"eslint": "^9.0.0",
|
|
68
|
+
"@eslint/js": "^9.0.0",
|
|
69
|
+
"typescript-eslint": "^8.0.0"
|
|
70
|
+
},
|
|
71
|
+
"packageManager": "pnpm@10.33.0"
|
|
72
|
+
}
|