@mcp-z/client 1.0.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/AGENTS.md +159 -0
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/cjs/auth/capability-discovery.d.cts +25 -0
- package/dist/cjs/auth/capability-discovery.d.ts +25 -0
- package/dist/cjs/auth/capability-discovery.js +280 -0
- package/dist/cjs/auth/capability-discovery.js.map +1 -0
- package/dist/cjs/auth/index.d.cts +9 -0
- package/dist/cjs/auth/index.d.ts +9 -0
- package/dist/cjs/auth/index.js +28 -0
- package/dist/cjs/auth/index.js.map +1 -0
- package/dist/cjs/auth/interactive-oauth-flow.d.cts +58 -0
- package/dist/cjs/auth/interactive-oauth-flow.d.ts +58 -0
- package/dist/cjs/auth/interactive-oauth-flow.js +537 -0
- package/dist/cjs/auth/interactive-oauth-flow.js.map +1 -0
- package/dist/cjs/auth/oauth-callback-listener.d.cts +56 -0
- package/dist/cjs/auth/oauth-callback-listener.d.ts +56 -0
- package/dist/cjs/auth/oauth-callback-listener.js +333 -0
- package/dist/cjs/auth/oauth-callback-listener.js.map +1 -0
- package/dist/cjs/auth/pkce.d.cts +17 -0
- package/dist/cjs/auth/pkce.d.ts +17 -0
- package/dist/cjs/auth/pkce.js +192 -0
- package/dist/cjs/auth/pkce.js.map +1 -0
- package/dist/cjs/auth/rfc9728-discovery.d.cts +34 -0
- package/dist/cjs/auth/rfc9728-discovery.d.ts +34 -0
- package/dist/cjs/auth/rfc9728-discovery.js +436 -0
- package/dist/cjs/auth/rfc9728-discovery.js.map +1 -0
- package/dist/cjs/auth/types.d.cts +137 -0
- package/dist/cjs/auth/types.d.ts +137 -0
- package/dist/cjs/auth/types.js +9 -0
- package/dist/cjs/auth/types.js.map +1 -0
- package/dist/cjs/client-helpers.d.cts +55 -0
- package/dist/cjs/client-helpers.d.ts +55 -0
- package/dist/cjs/client-helpers.js +128 -0
- package/dist/cjs/client-helpers.js.map +1 -0
- package/dist/cjs/config/server-loader.d.cts +27 -0
- package/dist/cjs/config/server-loader.d.ts +27 -0
- package/dist/cjs/config/server-loader.js +111 -0
- package/dist/cjs/config/server-loader.js.map +1 -0
- package/dist/cjs/config/validate-config.d.cts +15 -0
- package/dist/cjs/config/validate-config.d.ts +15 -0
- package/dist/cjs/config/validate-config.js +128 -0
- package/dist/cjs/config/validate-config.js.map +1 -0
- package/dist/cjs/connection/connect-client.d.cts +59 -0
- package/dist/cjs/connection/connect-client.d.ts +59 -0
- package/dist/cjs/connection/connect-client.js +536 -0
- package/dist/cjs/connection/connect-client.js.map +1 -0
- package/dist/cjs/connection/existing-process-transport.d.cts +40 -0
- package/dist/cjs/connection/existing-process-transport.d.ts +40 -0
- package/dist/cjs/connection/existing-process-transport.js +274 -0
- package/dist/cjs/connection/existing-process-transport.js.map +1 -0
- package/dist/cjs/connection/types.d.cts +61 -0
- package/dist/cjs/connection/types.d.ts +61 -0
- package/dist/cjs/connection/types.js +53 -0
- package/dist/cjs/connection/types.js.map +1 -0
- package/dist/cjs/connection/wait-for-http-ready.d.cts +15 -0
- package/dist/cjs/connection/wait-for-http-ready.d.ts +15 -0
- package/dist/cjs/connection/wait-for-http-ready.js +232 -0
- package/dist/cjs/connection/wait-for-http-ready.js.map +1 -0
- package/dist/cjs/dcr/dcr-authenticator.d.cts +73 -0
- package/dist/cjs/dcr/dcr-authenticator.d.ts +73 -0
- package/dist/cjs/dcr/dcr-authenticator.js +655 -0
- package/dist/cjs/dcr/dcr-authenticator.js.map +1 -0
- package/dist/cjs/dcr/dynamic-client-registrar.d.cts +28 -0
- package/dist/cjs/dcr/dynamic-client-registrar.d.ts +28 -0
- package/dist/cjs/dcr/dynamic-client-registrar.js +245 -0
- package/dist/cjs/dcr/dynamic-client-registrar.js.map +1 -0
- package/dist/cjs/dcr/index.d.cts +8 -0
- package/dist/cjs/dcr/index.d.ts +8 -0
- package/dist/cjs/dcr/index.js +24 -0
- package/dist/cjs/dcr/index.js.map +1 -0
- package/dist/cjs/index.d.cts +21 -0
- package/dist/cjs/index.d.ts +21 -0
- package/dist/cjs/index.js +94 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/monkey-patches.d.cts +6 -0
- package/dist/cjs/monkey-patches.d.ts +6 -0
- package/dist/cjs/monkey-patches.js +236 -0
- package/dist/cjs/monkey-patches.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/response-wrappers.d.cts +41 -0
- package/dist/cjs/response-wrappers.d.ts +41 -0
- package/dist/cjs/response-wrappers.js +443 -0
- package/dist/cjs/response-wrappers.js.map +1 -0
- package/dist/cjs/search/index.d.cts +6 -0
- package/dist/cjs/search/index.d.ts +6 -0
- package/dist/cjs/search/index.js +25 -0
- package/dist/cjs/search/index.js.map +1 -0
- package/dist/cjs/search/search.d.cts +22 -0
- package/dist/cjs/search/search.d.ts +22 -0
- package/dist/cjs/search/search.js +630 -0
- package/dist/cjs/search/search.js.map +1 -0
- package/dist/cjs/search/types.d.cts +122 -0
- package/dist/cjs/search/types.d.ts +122 -0
- package/dist/cjs/search/types.js +10 -0
- package/dist/cjs/search/types.js.map +1 -0
- package/dist/cjs/spawn/spawn-server.d.cts +83 -0
- package/dist/cjs/spawn/spawn-server.d.ts +83 -0
- package/dist/cjs/spawn/spawn-server.js +410 -0
- package/dist/cjs/spawn/spawn-server.js.map +1 -0
- package/dist/cjs/spawn/spawn-servers.d.cts +151 -0
- package/dist/cjs/spawn/spawn-servers.d.ts +151 -0
- package/dist/cjs/spawn/spawn-servers.js +911 -0
- package/dist/cjs/spawn/spawn-servers.js.map +1 -0
- package/dist/cjs/types.d.cts +11 -0
- package/dist/cjs/types.d.ts +11 -0
- package/dist/cjs/types.js +10 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/logger.d.cts +24 -0
- package/dist/cjs/utils/logger.d.ts +24 -0
- package/dist/cjs/utils/logger.js +80 -0
- package/dist/cjs/utils/logger.js.map +1 -0
- package/dist/cjs/utils/path-utils.d.cts +45 -0
- package/dist/cjs/utils/path-utils.d.ts +45 -0
- package/dist/cjs/utils/path-utils.js +158 -0
- package/dist/cjs/utils/path-utils.js.map +1 -0
- package/dist/cjs/utils/sanitizer.d.cts +30 -0
- package/dist/cjs/utils/sanitizer.d.ts +30 -0
- package/dist/cjs/utils/sanitizer.js +124 -0
- package/dist/cjs/utils/sanitizer.js.map +1 -0
- package/dist/esm/auth/capability-discovery.d.ts +25 -0
- package/dist/esm/auth/capability-discovery.js +110 -0
- package/dist/esm/auth/capability-discovery.js.map +1 -0
- package/dist/esm/auth/index.d.ts +9 -0
- package/dist/esm/auth/index.js +6 -0
- package/dist/esm/auth/index.js.map +1 -0
- package/dist/esm/auth/interactive-oauth-flow.d.ts +58 -0
- package/dist/esm/auth/interactive-oauth-flow.js +217 -0
- package/dist/esm/auth/interactive-oauth-flow.js.map +1 -0
- package/dist/esm/auth/oauth-callback-listener.d.ts +56 -0
- package/dist/esm/auth/oauth-callback-listener.js +166 -0
- package/dist/esm/auth/oauth-callback-listener.js.map +1 -0
- package/dist/esm/auth/pkce.d.ts +17 -0
- package/dist/esm/auth/pkce.js +41 -0
- package/dist/esm/auth/pkce.js.map +1 -0
- package/dist/esm/auth/rfc9728-discovery.d.ts +34 -0
- package/dist/esm/auth/rfc9728-discovery.js +157 -0
- package/dist/esm/auth/rfc9728-discovery.js.map +1 -0
- package/dist/esm/auth/types.d.ts +137 -0
- package/dist/esm/auth/types.js +7 -0
- package/dist/esm/auth/types.js.map +1 -0
- package/dist/esm/client-helpers.d.ts +55 -0
- package/dist/esm/client-helpers.js +81 -0
- package/dist/esm/client-helpers.js.map +1 -0
- package/dist/esm/config/server-loader.d.ts +27 -0
- package/dist/esm/config/server-loader.js +49 -0
- package/dist/esm/config/server-loader.js.map +1 -0
- package/dist/esm/config/validate-config.d.ts +15 -0
- package/dist/esm/config/validate-config.js +76 -0
- package/dist/esm/config/validate-config.js.map +1 -0
- package/dist/esm/connection/connect-client.d.ts +59 -0
- package/dist/esm/connection/connect-client.js +272 -0
- package/dist/esm/connection/connect-client.js.map +1 -0
- package/dist/esm/connection/existing-process-transport.d.ts +40 -0
- package/dist/esm/connection/existing-process-transport.js +103 -0
- package/dist/esm/connection/existing-process-transport.js.map +1 -0
- package/dist/esm/connection/types.d.ts +61 -0
- package/dist/esm/connection/types.js +34 -0
- package/dist/esm/connection/types.js.map +1 -0
- package/dist/esm/connection/wait-for-http-ready.d.ts +15 -0
- package/dist/esm/connection/wait-for-http-ready.js +43 -0
- package/dist/esm/connection/wait-for-http-ready.js.map +1 -0
- package/dist/esm/dcr/dcr-authenticator.d.ts +73 -0
- package/dist/esm/dcr/dcr-authenticator.js +235 -0
- package/dist/esm/dcr/dcr-authenticator.js.map +1 -0
- package/dist/esm/dcr/dynamic-client-registrar.d.ts +28 -0
- package/dist/esm/dcr/dynamic-client-registrar.js +66 -0
- package/dist/esm/dcr/dynamic-client-registrar.js.map +1 -0
- package/dist/esm/dcr/index.d.ts +8 -0
- package/dist/esm/dcr/index.js +5 -0
- package/dist/esm/dcr/index.js.map +1 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/monkey-patches.d.ts +6 -0
- package/dist/esm/monkey-patches.js +32 -0
- package/dist/esm/monkey-patches.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/response-wrappers.d.ts +41 -0
- package/dist/esm/response-wrappers.js +201 -0
- package/dist/esm/response-wrappers.js.map +1 -0
- package/dist/esm/search/index.d.ts +6 -0
- package/dist/esm/search/index.js +3 -0
- package/dist/esm/search/index.js.map +1 -0
- package/dist/esm/search/search.d.ts +22 -0
- package/dist/esm/search/search.js +236 -0
- package/dist/esm/search/search.js.map +1 -0
- package/dist/esm/search/types.d.ts +122 -0
- package/dist/esm/search/types.js +8 -0
- package/dist/esm/search/types.js.map +1 -0
- package/dist/esm/spawn/spawn-server.d.ts +83 -0
- package/dist/esm/spawn/spawn-server.js +145 -0
- package/dist/esm/spawn/spawn-server.js.map +1 -0
- package/dist/esm/spawn/spawn-servers.d.ts +151 -0
- package/dist/esm/spawn/spawn-servers.js +406 -0
- package/dist/esm/spawn/spawn-servers.js.map +1 -0
- package/dist/esm/types.d.ts +11 -0
- package/dist/esm/types.js +9 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/logger.d.ts +24 -0
- package/dist/esm/utils/logger.js +59 -0
- package/dist/esm/utils/logger.js.map +1 -0
- package/dist/esm/utils/path-utils.d.ts +45 -0
- package/dist/esm/utils/path-utils.js +89 -0
- package/dist/esm/utils/path-utils.js.map +1 -0
- package/dist/esm/utils/sanitizer.d.ts +30 -0
- package/dist/esm/utils/sanitizer.js +43 -0
- package/dist/esm/utils/sanitizer.js.map +1 -0
- package/package.json +92 -0
- package/schemas/servers.d.ts +90 -0
- package/schemas/servers.schema.json +104 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search types for MCP capability discovery
|
|
3
|
+
*
|
|
4
|
+
* Enables agents to discover tools, prompts, and resources without
|
|
5
|
+
* loading full schemas into context.
|
|
6
|
+
*/
|
|
7
|
+
import type { PromptArgument } from '../connection/types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Types of MCP capabilities that can be searched
|
|
10
|
+
*/
|
|
11
|
+
export type CapabilityType = 'tool' | 'prompt' | 'resource';
|
|
12
|
+
/**
|
|
13
|
+
* Fields that can be searched within capabilities
|
|
14
|
+
*/
|
|
15
|
+
export type SearchField = 'name' | 'description' | 'schema' | 'server';
|
|
16
|
+
/**
|
|
17
|
+
* Options for configuring search behavior
|
|
18
|
+
*/
|
|
19
|
+
export interface SearchOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Filter to specific capability types
|
|
22
|
+
* @default ['tool', 'prompt', 'resource']
|
|
23
|
+
*/
|
|
24
|
+
types?: CapabilityType[];
|
|
25
|
+
/**
|
|
26
|
+
* Filter to specific servers by name
|
|
27
|
+
* @default all servers in config
|
|
28
|
+
*/
|
|
29
|
+
servers?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Which fields to search within
|
|
32
|
+
* @default ['name', 'description', 'schema']
|
|
33
|
+
*/
|
|
34
|
+
searchFields?: SearchField[];
|
|
35
|
+
/**
|
|
36
|
+
* Maximum number of results to return
|
|
37
|
+
* @default 20
|
|
38
|
+
*/
|
|
39
|
+
limit?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Minimum relevance score (0-1) for results
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
threshold?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A single search result representing a matched capability
|
|
48
|
+
*/
|
|
49
|
+
export interface SearchResult {
|
|
50
|
+
/** The type of capability */
|
|
51
|
+
type: CapabilityType;
|
|
52
|
+
/** The server that provides this capability */
|
|
53
|
+
server: string;
|
|
54
|
+
/** The name of the capability */
|
|
55
|
+
name: string;
|
|
56
|
+
/** Human-readable description (may be truncated) */
|
|
57
|
+
description: string | undefined;
|
|
58
|
+
/** Which fields matched the search query */
|
|
59
|
+
matchedOn: string[];
|
|
60
|
+
/** Relevance score from 0 (low) to 1 (high) */
|
|
61
|
+
score: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Complete search response
|
|
65
|
+
*/
|
|
66
|
+
export interface SearchResponse {
|
|
67
|
+
/** The original search query */
|
|
68
|
+
query: string;
|
|
69
|
+
/** Matching results, sorted by relevance */
|
|
70
|
+
results: SearchResult[];
|
|
71
|
+
/** Total number of matches before limit was applied */
|
|
72
|
+
total: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Internal representation of a tool for indexing
|
|
76
|
+
*/
|
|
77
|
+
export interface IndexedTool {
|
|
78
|
+
type: 'tool';
|
|
79
|
+
server: string;
|
|
80
|
+
name: string;
|
|
81
|
+
description: string | undefined;
|
|
82
|
+
/** Flattened searchable text from inputSchema property descriptions */
|
|
83
|
+
schemaText: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Internal representation of a prompt for indexing
|
|
87
|
+
*/
|
|
88
|
+
export interface IndexedPrompt {
|
|
89
|
+
type: 'prompt';
|
|
90
|
+
server: string;
|
|
91
|
+
name: string;
|
|
92
|
+
description: string | undefined;
|
|
93
|
+
/** Flattened searchable text from arguments */
|
|
94
|
+
argumentsText: string;
|
|
95
|
+
arguments: PromptArgument[] | undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Internal representation of a resource for indexing
|
|
99
|
+
*/
|
|
100
|
+
export interface IndexedResource {
|
|
101
|
+
type: 'resource';
|
|
102
|
+
server: string;
|
|
103
|
+
name: string;
|
|
104
|
+
description: string | undefined;
|
|
105
|
+
uri: string;
|
|
106
|
+
mimeType: string | undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Union of all indexed capability types
|
|
110
|
+
*/
|
|
111
|
+
export type IndexedCapability = IndexedTool | IndexedPrompt | IndexedResource;
|
|
112
|
+
/**
|
|
113
|
+
* Index containing all capabilities from connected servers
|
|
114
|
+
*/
|
|
115
|
+
export interface CapabilityIndex {
|
|
116
|
+
/** All indexed capabilities */
|
|
117
|
+
capabilities: IndexedCapability[];
|
|
118
|
+
/** Servers that were indexed */
|
|
119
|
+
servers: string[];
|
|
120
|
+
/** When the index was created */
|
|
121
|
+
indexedAt: Date;
|
|
122
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search types for MCP capability discovery
|
|
3
|
+
*
|
|
4
|
+
* Enables agents to discover tools, prompts, and resources without
|
|
5
|
+
* loading full schemas into context.
|
|
6
|
+
*/
|
|
7
|
+
import type { PromptArgument } from '../connection/types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Types of MCP capabilities that can be searched
|
|
10
|
+
*/
|
|
11
|
+
export type CapabilityType = 'tool' | 'prompt' | 'resource';
|
|
12
|
+
/**
|
|
13
|
+
* Fields that can be searched within capabilities
|
|
14
|
+
*/
|
|
15
|
+
export type SearchField = 'name' | 'description' | 'schema' | 'server';
|
|
16
|
+
/**
|
|
17
|
+
* Options for configuring search behavior
|
|
18
|
+
*/
|
|
19
|
+
export interface SearchOptions {
|
|
20
|
+
/**
|
|
21
|
+
* Filter to specific capability types
|
|
22
|
+
* @default ['tool', 'prompt', 'resource']
|
|
23
|
+
*/
|
|
24
|
+
types?: CapabilityType[];
|
|
25
|
+
/**
|
|
26
|
+
* Filter to specific servers by name
|
|
27
|
+
* @default all servers in config
|
|
28
|
+
*/
|
|
29
|
+
servers?: string[];
|
|
30
|
+
/**
|
|
31
|
+
* Which fields to search within
|
|
32
|
+
* @default ['name', 'description', 'schema']
|
|
33
|
+
*/
|
|
34
|
+
searchFields?: SearchField[];
|
|
35
|
+
/**
|
|
36
|
+
* Maximum number of results to return
|
|
37
|
+
* @default 20
|
|
38
|
+
*/
|
|
39
|
+
limit?: number;
|
|
40
|
+
/**
|
|
41
|
+
* Minimum relevance score (0-1) for results
|
|
42
|
+
* @default 0
|
|
43
|
+
*/
|
|
44
|
+
threshold?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* A single search result representing a matched capability
|
|
48
|
+
*/
|
|
49
|
+
export interface SearchResult {
|
|
50
|
+
/** The type of capability */
|
|
51
|
+
type: CapabilityType;
|
|
52
|
+
/** The server that provides this capability */
|
|
53
|
+
server: string;
|
|
54
|
+
/** The name of the capability */
|
|
55
|
+
name: string;
|
|
56
|
+
/** Human-readable description (may be truncated) */
|
|
57
|
+
description: string | undefined;
|
|
58
|
+
/** Which fields matched the search query */
|
|
59
|
+
matchedOn: string[];
|
|
60
|
+
/** Relevance score from 0 (low) to 1 (high) */
|
|
61
|
+
score: number;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Complete search response
|
|
65
|
+
*/
|
|
66
|
+
export interface SearchResponse {
|
|
67
|
+
/** The original search query */
|
|
68
|
+
query: string;
|
|
69
|
+
/** Matching results, sorted by relevance */
|
|
70
|
+
results: SearchResult[];
|
|
71
|
+
/** Total number of matches before limit was applied */
|
|
72
|
+
total: number;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Internal representation of a tool for indexing
|
|
76
|
+
*/
|
|
77
|
+
export interface IndexedTool {
|
|
78
|
+
type: 'tool';
|
|
79
|
+
server: string;
|
|
80
|
+
name: string;
|
|
81
|
+
description: string | undefined;
|
|
82
|
+
/** Flattened searchable text from inputSchema property descriptions */
|
|
83
|
+
schemaText: string;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Internal representation of a prompt for indexing
|
|
87
|
+
*/
|
|
88
|
+
export interface IndexedPrompt {
|
|
89
|
+
type: 'prompt';
|
|
90
|
+
server: string;
|
|
91
|
+
name: string;
|
|
92
|
+
description: string | undefined;
|
|
93
|
+
/** Flattened searchable text from arguments */
|
|
94
|
+
argumentsText: string;
|
|
95
|
+
arguments: PromptArgument[] | undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Internal representation of a resource for indexing
|
|
99
|
+
*/
|
|
100
|
+
export interface IndexedResource {
|
|
101
|
+
type: 'resource';
|
|
102
|
+
server: string;
|
|
103
|
+
name: string;
|
|
104
|
+
description: string | undefined;
|
|
105
|
+
uri: string;
|
|
106
|
+
mimeType: string | undefined;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Union of all indexed capability types
|
|
110
|
+
*/
|
|
111
|
+
export type IndexedCapability = IndexedTool | IndexedPrompt | IndexedResource;
|
|
112
|
+
/**
|
|
113
|
+
* Index containing all capabilities from connected servers
|
|
114
|
+
*/
|
|
115
|
+
export interface CapabilityIndex {
|
|
116
|
+
/** All indexed capabilities */
|
|
117
|
+
capabilities: IndexedCapability[];
|
|
118
|
+
/** Servers that were indexed */
|
|
119
|
+
servers: string[];
|
|
120
|
+
/** When the index was created */
|
|
121
|
+
indexedAt: Date;
|
|
122
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Search types for MCP capability discovery
|
|
3
|
+
*
|
|
4
|
+
* Enables agents to discover tools, prompts, and resources without
|
|
5
|
+
* loading full schemas into context.
|
|
6
|
+
*/ "use strict";
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/libs/client/src/search/types.ts"],"sourcesContent":["/**\n * Search types for MCP capability discovery\n *\n * Enables agents to discover tools, prompts, and resources without\n * loading full schemas into context.\n */\n\nimport type { PromptArgument } from '../connection/types.ts';\n\n/**\n * Types of MCP capabilities that can be searched\n */\nexport type CapabilityType = 'tool' | 'prompt' | 'resource';\n\n/**\n * Fields that can be searched within capabilities\n */\nexport type SearchField = 'name' | 'description' | 'schema' | 'server';\n\n/**\n * Options for configuring search behavior\n */\nexport interface SearchOptions {\n /**\n * Filter to specific capability types\n * @default ['tool', 'prompt', 'resource']\n */\n types?: CapabilityType[];\n\n /**\n * Filter to specific servers by name\n * @default all servers in config\n */\n servers?: string[];\n\n /**\n * Which fields to search within\n * @default ['name', 'description', 'schema']\n */\n searchFields?: SearchField[];\n\n /**\n * Maximum number of results to return\n * @default 20\n */\n limit?: number;\n\n /**\n * Minimum relevance score (0-1) for results\n * @default 0\n */\n threshold?: number;\n}\n\n/**\n * A single search result representing a matched capability\n */\nexport interface SearchResult {\n /** The type of capability */\n type: CapabilityType;\n\n /** The server that provides this capability */\n server: string;\n\n /** The name of the capability */\n name: string;\n\n /** Human-readable description (may be truncated) */\n description: string | undefined;\n\n /** Which fields matched the search query */\n matchedOn: string[];\n\n /** Relevance score from 0 (low) to 1 (high) */\n score: number;\n}\n\n/**\n * Complete search response\n */\nexport interface SearchResponse {\n /** The original search query */\n query: string;\n\n /** Matching results, sorted by relevance */\n results: SearchResult[];\n\n /** Total number of matches before limit was applied */\n total: number;\n}\n\n/**\n * Internal representation of a tool for indexing\n */\nexport interface IndexedTool {\n type: 'tool';\n server: string;\n name: string;\n description: string | undefined;\n /** Flattened searchable text from inputSchema property descriptions */\n schemaText: string;\n}\n\n/**\n * Internal representation of a prompt for indexing\n */\nexport interface IndexedPrompt {\n type: 'prompt';\n server: string;\n name: string;\n description: string | undefined;\n /** Flattened searchable text from arguments */\n argumentsText: string;\n arguments: PromptArgument[] | undefined;\n}\n\n/**\n * Internal representation of a resource for indexing\n */\nexport interface IndexedResource {\n type: 'resource';\n server: string;\n name: string;\n description: string | undefined;\n uri: string;\n mimeType: string | undefined;\n}\n\n/**\n * Union of all indexed capability types\n */\nexport type IndexedCapability = IndexedTool | IndexedPrompt | IndexedResource;\n\n/**\n * Index containing all capabilities from connected servers\n */\nexport interface CapabilityIndex {\n /** All indexed capabilities */\n capabilities: IndexedCapability[];\n\n /** Servers that were indexed */\n servers: string[];\n\n /** When the index was created */\n indexedAt: Date;\n}\n"],"names":[],"mappings":"AAAA;;;;;CAKC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level single server spawning utilities.
|
|
3
|
+
* Provides core process spawning with path resolution, environment management, and lifecycle control.
|
|
4
|
+
*/
|
|
5
|
+
import { type ChildProcess, type StdioOptions } from 'child_process';
|
|
6
|
+
/**
|
|
7
|
+
* Options for spawning a single server process.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export interface SpawnProcessOptions {
|
|
11
|
+
/** Server name for logging */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Command to execute (e.g., 'node', 'npx') */
|
|
14
|
+
command: string;
|
|
15
|
+
/** Command arguments (paths will be resolved relative to cwd) */
|
|
16
|
+
args?: string[];
|
|
17
|
+
/** Working directory (must be absolute path) */
|
|
18
|
+
cwd?: string;
|
|
19
|
+
/** Additional environment variables (merged with process.env) */
|
|
20
|
+
env?: Record<string, string>;
|
|
21
|
+
/** Standard I/O configuration */
|
|
22
|
+
stdio?: StdioOptions;
|
|
23
|
+
/** Use shell for command execution (default: false, true on Windows) */
|
|
24
|
+
shell?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Handle to a spawned server process.
|
|
28
|
+
* Provides access to the process, resolved config, and lifecycle control.
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
export interface ServerProcess {
|
|
32
|
+
/**
|
|
33
|
+
* The resolved server configuration that was actually used.
|
|
34
|
+
* Useful for debugging and understanding what was spawned.
|
|
35
|
+
*/
|
|
36
|
+
config: {
|
|
37
|
+
name: string;
|
|
38
|
+
command: string;
|
|
39
|
+
args: string[];
|
|
40
|
+
cwd: string;
|
|
41
|
+
env: Record<string, string>;
|
|
42
|
+
stdio: StdioOptions;
|
|
43
|
+
shell: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The spawned child process.
|
|
47
|
+
*/
|
|
48
|
+
process: ChildProcess;
|
|
49
|
+
/**
|
|
50
|
+
* Close the server gracefully.
|
|
51
|
+
* Sends the specified signal (default: SIGINT), then SIGKILL after timeout.
|
|
52
|
+
*
|
|
53
|
+
* @param signal - Signal to send (default: SIGINT)
|
|
54
|
+
* @param opts - Options including timeout
|
|
55
|
+
* @returns Promise resolving to whether the process timed out and was force-killed
|
|
56
|
+
*/
|
|
57
|
+
close: (signal?: NodeJS.Signals, opts?: {
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
}) => Promise<{
|
|
60
|
+
timedOut: boolean;
|
|
61
|
+
killed: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Spawn a single server process with path resolution and environment management.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
* @param opts - Server spawn options
|
|
69
|
+
* @returns ServerProcess handle with resolved config, process, and stop function
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const handle = spawnProcess({
|
|
73
|
+
* name: 'echo',
|
|
74
|
+
* command: 'node',
|
|
75
|
+
* args: ['./bin/server.js', '--port', '3000'],
|
|
76
|
+
* cwd: '/home/user/project/test/lib/servers/echo',
|
|
77
|
+
* env: { LOG_LEVEL: 'error' }
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Later...
|
|
81
|
+
* await handle.close();
|
|
82
|
+
*/
|
|
83
|
+
export declare function spawnProcess(opts: SpawnProcessOptions): ServerProcess;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Low-level single server spawning utilities.
|
|
3
|
+
* Provides core process spawning with path resolution, environment management, and lifecycle control.
|
|
4
|
+
*/
|
|
5
|
+
import { type ChildProcess, type StdioOptions } from 'child_process';
|
|
6
|
+
/**
|
|
7
|
+
* Options for spawning a single server process.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export interface SpawnProcessOptions {
|
|
11
|
+
/** Server name for logging */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Command to execute (e.g., 'node', 'npx') */
|
|
14
|
+
command: string;
|
|
15
|
+
/** Command arguments (paths will be resolved relative to cwd) */
|
|
16
|
+
args?: string[];
|
|
17
|
+
/** Working directory (must be absolute path) */
|
|
18
|
+
cwd?: string;
|
|
19
|
+
/** Additional environment variables (merged with process.env) */
|
|
20
|
+
env?: Record<string, string>;
|
|
21
|
+
/** Standard I/O configuration */
|
|
22
|
+
stdio?: StdioOptions;
|
|
23
|
+
/** Use shell for command execution (default: false, true on Windows) */
|
|
24
|
+
shell?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Handle to a spawned server process.
|
|
28
|
+
* Provides access to the process, resolved config, and lifecycle control.
|
|
29
|
+
* @hidden
|
|
30
|
+
*/
|
|
31
|
+
export interface ServerProcess {
|
|
32
|
+
/**
|
|
33
|
+
* The resolved server configuration that was actually used.
|
|
34
|
+
* Useful for debugging and understanding what was spawned.
|
|
35
|
+
*/
|
|
36
|
+
config: {
|
|
37
|
+
name: string;
|
|
38
|
+
command: string;
|
|
39
|
+
args: string[];
|
|
40
|
+
cwd: string;
|
|
41
|
+
env: Record<string, string>;
|
|
42
|
+
stdio: StdioOptions;
|
|
43
|
+
shell: boolean;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* The spawned child process.
|
|
47
|
+
*/
|
|
48
|
+
process: ChildProcess;
|
|
49
|
+
/**
|
|
50
|
+
* Close the server gracefully.
|
|
51
|
+
* Sends the specified signal (default: SIGINT), then SIGKILL after timeout.
|
|
52
|
+
*
|
|
53
|
+
* @param signal - Signal to send (default: SIGINT)
|
|
54
|
+
* @param opts - Options including timeout
|
|
55
|
+
* @returns Promise resolving to whether the process timed out and was force-killed
|
|
56
|
+
*/
|
|
57
|
+
close: (signal?: NodeJS.Signals, opts?: {
|
|
58
|
+
timeoutMs?: number;
|
|
59
|
+
}) => Promise<{
|
|
60
|
+
timedOut: boolean;
|
|
61
|
+
killed: boolean;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Spawn a single server process with path resolution and environment management.
|
|
66
|
+
*
|
|
67
|
+
* @internal
|
|
68
|
+
* @param opts - Server spawn options
|
|
69
|
+
* @returns ServerProcess handle with resolved config, process, and stop function
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* const handle = spawnProcess({
|
|
73
|
+
* name: 'echo',
|
|
74
|
+
* command: 'node',
|
|
75
|
+
* args: ['./bin/server.js', '--port', '3000'],
|
|
76
|
+
* cwd: '/home/user/project/test/lib/servers/echo',
|
|
77
|
+
* env: { LOG_LEVEL: 'error' }
|
|
78
|
+
* });
|
|
79
|
+
*
|
|
80
|
+
* // Later...
|
|
81
|
+
* await handle.close();
|
|
82
|
+
*/
|
|
83
|
+
export declare function spawnProcess(opts: SpawnProcessOptions): ServerProcess;
|