open-agent-sdk 0.1.0-alpha.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 +284 -0
- package/README.zh.md +285 -0
- package/dist/agent/agent-definition.d.ts +107 -0
- package/dist/agent/agent-definition.d.ts.map +1 -0
- package/dist/agent/agent-definition.js +90 -0
- package/dist/agent/agent-definition.js.map +1 -0
- package/dist/agent/react-loop.d.ts +117 -0
- package/dist/agent/react-loop.d.ts.map +1 -0
- package/dist/agent/react-loop.js +674 -0
- package/dist/agent/react-loop.js.map +1 -0
- package/dist/agent/subagent-runner.d.ts +67 -0
- package/dist/agent/subagent-runner.d.ts.map +1 -0
- package/dist/agent/subagent-runner.js +168 -0
- package/dist/agent/subagent-runner.js.map +1 -0
- package/dist/hooks/index.d.ts +8 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/inputs.d.ts +56 -0
- package/dist/hooks/inputs.d.ts.map +1 -0
- package/dist/hooks/inputs.js +150 -0
- package/dist/hooks/inputs.js.map +1 -0
- package/dist/hooks/manager.d.ts +63 -0
- package/dist/hooks/manager.d.ts.map +1 -0
- package/dist/hooks/manager.js +137 -0
- package/dist/hooks/manager.js.map +1 -0
- package/dist/hooks/types.d.ts +191 -0
- package/dist/hooks/types.d.ts.map +1 -0
- package/dist/hooks/types.js +6 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +218 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/errors.d.ts +26 -0
- package/dist/mcp/errors.d.ts.map +1 -0
- package/dist/mcp/errors.js +43 -0
- package/dist/mcp/errors.js.map +1 -0
- package/dist/mcp/index.d.ts +11 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +13 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/manager.d.ts +50 -0
- package/dist/mcp/manager.d.ts.map +1 -0
- package/dist/mcp/manager.js +170 -0
- package/dist/mcp/manager.js.map +1 -0
- package/dist/mcp/server-registry.d.ts +48 -0
- package/dist/mcp/server-registry.d.ts.map +1 -0
- package/dist/mcp/server-registry.js +121 -0
- package/dist/mcp/server-registry.js.map +1 -0
- package/dist/mcp/tool-adapter.d.ts +42 -0
- package/dist/mcp/tool-adapter.d.ts.map +1 -0
- package/dist/mcp/tool-adapter.js +89 -0
- package/dist/mcp/tool-adapter.js.map +1 -0
- package/dist/mcp/types.d.ts +74 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +21 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/permissions/index.d.ts +3 -0
- package/dist/permissions/index.d.ts.map +1 -0
- package/dist/permissions/index.js +4 -0
- package/dist/permissions/index.js.map +1 -0
- package/dist/permissions/manager.d.ts +40 -0
- package/dist/permissions/manager.d.ts.map +1 -0
- package/dist/permissions/manager.js +115 -0
- package/dist/permissions/manager.js.map +1 -0
- package/dist/permissions/types.d.ts +124 -0
- package/dist/permissions/types.d.ts.map +1 -0
- package/dist/permissions/types.js +25 -0
- package/dist/permissions/types.js.map +1 -0
- package/dist/providers/anthropic.d.ts +18 -0
- package/dist/providers/anthropic.d.ts.map +1 -0
- package/dist/providers/anthropic.js +126 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/base.d.ts +85 -0
- package/dist/providers/base.d.ts.map +1 -0
- package/dist/providers/base.js +36 -0
- package/dist/providers/base.js.map +1 -0
- package/dist/providers/google.d.ts +12 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +123 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/openai.d.ts +12 -0
- package/dist/providers/openai.d.ts.map +1 -0
- package/dist/providers/openai.js +110 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/session/factory.d.ts +156 -0
- package/dist/session/factory.d.ts.map +1 -0
- package/dist/session/factory.js +311 -0
- package/dist/session/factory.js.map +1 -0
- package/dist/session/index.d.ts +8 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +7 -0
- package/dist/session/index.js.map +1 -0
- package/dist/session/session.d.ts +144 -0
- package/dist/session/session.d.ts.map +1 -0
- package/dist/session/session.js +319 -0
- package/dist/session/session.js.map +1 -0
- package/dist/session/storage.d.ts +105 -0
- package/dist/session/storage.d.ts.map +1 -0
- package/dist/session/storage.js +148 -0
- package/dist/session/storage.js.map +1 -0
- package/dist/tools/ask-user-question.d.ts +31 -0
- package/dist/tools/ask-user-question.d.ts.map +1 -0
- package/dist/tools/ask-user-question.js +66 -0
- package/dist/tools/ask-user-question.js.map +1 -0
- package/dist/tools/bash-output.d.ts +22 -0
- package/dist/tools/bash-output.d.ts.map +1 -0
- package/dist/tools/bash-output.js +43 -0
- package/dist/tools/bash-output.js.map +1 -0
- package/dist/tools/bash.d.ts +36 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/bash.js +161 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/edit.d.ts +24 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/edit.js +83 -0
- package/dist/tools/edit.js.map +1 -0
- package/dist/tools/glob.d.ts +22 -0
- package/dist/tools/glob.d.ts.map +1 -0
- package/dist/tools/glob.js +248 -0
- package/dist/tools/glob.js.map +1 -0
- package/dist/tools/grep.d.ts +39 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/grep.js +312 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/kill-bash.d.ts +19 -0
- package/dist/tools/kill-bash.d.ts.map +1 -0
- package/dist/tools/kill-bash.js +64 -0
- package/dist/tools/kill-bash.js.map +1 -0
- package/dist/tools/read.d.ts +26 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/read.js +87 -0
- package/dist/tools/read.js.map +1 -0
- package/dist/tools/registry.d.ts +32 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +91 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/task-create.d.ts +22 -0
- package/dist/tools/task-create.d.ts.map +1 -0
- package/dist/tools/task-create.js +42 -0
- package/dist/tools/task-create.js.map +1 -0
- package/dist/tools/task-get.d.ts +19 -0
- package/dist/tools/task-get.d.ts.map +1 -0
- package/dist/tools/task-get.js +38 -0
- package/dist/tools/task-get.js.map +1 -0
- package/dist/tools/task-list.d.ts +18 -0
- package/dist/tools/task-list.d.ts.map +1 -0
- package/dist/tools/task-list.js +27 -0
- package/dist/tools/task-list.js.map +1 -0
- package/dist/tools/task-storage.d.ts +6 -0
- package/dist/tools/task-storage.d.ts.map +1 -0
- package/dist/tools/task-storage.js +83 -0
- package/dist/tools/task-storage.js.map +1 -0
- package/dist/tools/task-update.d.ts +28 -0
- package/dist/tools/task-update.d.ts.map +1 -0
- package/dist/tools/task-update.js +118 -0
- package/dist/tools/task-update.js.map +1 -0
- package/dist/tools/task.d.ts +80 -0
- package/dist/tools/task.d.ts.map +1 -0
- package/dist/tools/task.js +99 -0
- package/dist/tools/task.js.map +1 -0
- package/dist/tools/web-fetch.d.ts +21 -0
- package/dist/tools/web-fetch.d.ts.map +1 -0
- package/dist/tools/web-fetch.js +124 -0
- package/dist/tools/web-fetch.js.map +1 -0
- package/dist/tools/web-search.d.ts +20 -0
- package/dist/tools/web-search.d.ts.map +1 -0
- package/dist/tools/web-search.js +127 -0
- package/dist/tools/web-search.js.map +1 -0
- package/dist/tools/write.d.ts +22 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/tools/write.js +46 -0
- package/dist/tools/write.js.map +1 -0
- package/dist/types/messages.d.ts +138 -0
- package/dist/types/messages.d.ts.map +1 -0
- package/dist/types/messages.js +88 -0
- package/dist/types/messages.js.map +1 -0
- package/dist/types/task.d.ts +29 -0
- package/dist/types/task.d.ts.map +1 -0
- package/dist/types/task.js +5 -0
- package/dist/types/task.js.map +1 -0
- package/dist/types/tools.d.ts +56 -0
- package/dist/types/tools.d.ts.map +1 -0
- package/dist/types/tools.js +25 -0
- package/dist/types/tools.js.map +1 -0
- package/dist/utils/logger.d.ts +19 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +46 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/uuid.d.ts +3 -0
- package/dist/utils/uuid.d.ts.map +1 -0
- package/dist/utils/uuid.js +5 -0
- package/dist/utils/uuid.js.map +1 -0
- package/package.json +38 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Open Agent SDK - Core API
|
|
3
|
+
* Single-query prompt function for one-shot agent interactions
|
|
4
|
+
*/
|
|
5
|
+
import { logger } from './utils/logger';
|
|
6
|
+
import { OpenAIProvider } from './providers/openai';
|
|
7
|
+
import { GoogleProvider } from './providers/google';
|
|
8
|
+
import { AnthropicProvider } from './providers/anthropic';
|
|
9
|
+
import { createDefaultRegistry } from './tools/registry';
|
|
10
|
+
import { ReActLoop } from './agent/react-loop';
|
|
11
|
+
import { createSession, resumeSession, forkSession } from './session/factory';
|
|
12
|
+
// ToolRegistry type used indirectly through createDefaultRegistry
|
|
13
|
+
// Export permission system
|
|
14
|
+
export { PermissionManager, SENSITIVE_TOOLS, EDIT_TOOLS, isSensitiveTool, isEditTool, } from './permissions';
|
|
15
|
+
/**
|
|
16
|
+
* Execute a single prompt with the agent
|
|
17
|
+
* @param prompt - User's question or task
|
|
18
|
+
* @param options - Configuration options
|
|
19
|
+
* @returns Promise with result, duration, and usage
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const result = await prompt("What files are in the current directory?", {
|
|
24
|
+
* model: "gpt-4o",
|
|
25
|
+
* apiKey: process.env.OPENAI_API_KEY,
|
|
26
|
+
* });
|
|
27
|
+
* console.log(result.result);
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export async function prompt(prompt, options) {
|
|
31
|
+
// Set log level from options or environment variable
|
|
32
|
+
const logLevel = options.logLevel ??
|
|
33
|
+
process.env.OPEN_AGENT_SDK_LOG_LEVEL ??
|
|
34
|
+
'info';
|
|
35
|
+
logger.setLevel(logLevel);
|
|
36
|
+
const startTime = Date.now();
|
|
37
|
+
// Get storage if provided
|
|
38
|
+
const storage = options.storage;
|
|
39
|
+
let session;
|
|
40
|
+
let sessionId;
|
|
41
|
+
// Handle resume/fork logic
|
|
42
|
+
if (options.resume && storage) {
|
|
43
|
+
if (options.forkSession) {
|
|
44
|
+
// Fork mode: create new session from existing one
|
|
45
|
+
session = await forkSession(options.resume, {
|
|
46
|
+
storage,
|
|
47
|
+
apiKey: options.apiKey,
|
|
48
|
+
logLevel,
|
|
49
|
+
model: options.model,
|
|
50
|
+
provider: options.provider,
|
|
51
|
+
permissionMode: options.permissionMode,
|
|
52
|
+
allowDangerouslySkipPermissions: options.allowDangerouslySkipPermissions,
|
|
53
|
+
canUseTool: options.canUseTool,
|
|
54
|
+
hooks: undefined, // Will be loaded from source session
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// Resume mode: continue existing session
|
|
59
|
+
session = await resumeSession(options.resume, {
|
|
60
|
+
storage,
|
|
61
|
+
apiKey: options.apiKey,
|
|
62
|
+
logLevel,
|
|
63
|
+
permissionMode: options.permissionMode,
|
|
64
|
+
allowDangerouslySkipPermissions: options.allowDangerouslySkipPermissions,
|
|
65
|
+
canUseTool: options.canUseTool,
|
|
66
|
+
hooks: undefined, // Will be loaded from source session
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
sessionId = session.id;
|
|
70
|
+
// Send the prompt message
|
|
71
|
+
await session.send(prompt);
|
|
72
|
+
// Collect all messages from the stream
|
|
73
|
+
let resultText = '';
|
|
74
|
+
let inputTokens = 0;
|
|
75
|
+
let outputTokens = 0;
|
|
76
|
+
for await (const message of session.stream()) {
|
|
77
|
+
if (message.type === 'assistant') {
|
|
78
|
+
// Extract text content from assistant message
|
|
79
|
+
const content = message.message.content;
|
|
80
|
+
if (typeof content === 'string') {
|
|
81
|
+
resultText = content;
|
|
82
|
+
}
|
|
83
|
+
else if (Array.isArray(content)) {
|
|
84
|
+
resultText = content
|
|
85
|
+
.filter((c) => c.type === 'text')
|
|
86
|
+
.map((c) => c.text)
|
|
87
|
+
.join('');
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Get usage from the session's messages (approximation)
|
|
92
|
+
// Note: For accurate token counts, we'd need to track usage during streaming
|
|
93
|
+
// This is a simplified approach
|
|
94
|
+
const messages = session.getMessages();
|
|
95
|
+
inputTokens = estimateTokens(messages.map((m) => JSON.stringify(m)).join(''));
|
|
96
|
+
outputTokens = estimateTokens(resultText);
|
|
97
|
+
const duration_ms = Date.now() - startTime;
|
|
98
|
+
return {
|
|
99
|
+
result: resultText,
|
|
100
|
+
duration_ms,
|
|
101
|
+
usage: {
|
|
102
|
+
input_tokens: inputTokens,
|
|
103
|
+
output_tokens: outputTokens,
|
|
104
|
+
},
|
|
105
|
+
session_id: sessionId,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
// No resume/fork - use original one-shot behavior
|
|
109
|
+
// Auto-detect provider from model name if not specified
|
|
110
|
+
const modelLower = options.model.toLowerCase();
|
|
111
|
+
const providerType = options.provider ??
|
|
112
|
+
(modelLower.includes('gemini') ? 'google' :
|
|
113
|
+
modelLower.includes('claude') ? 'anthropic' : 'openai');
|
|
114
|
+
// Get API key based on provider
|
|
115
|
+
const apiKey = options.apiKey ??
|
|
116
|
+
(providerType === 'google' ? process.env.GEMINI_API_KEY :
|
|
117
|
+
providerType === 'anthropic' ? process.env.ANTHROPIC_API_KEY : process.env.OPENAI_API_KEY);
|
|
118
|
+
if (!apiKey) {
|
|
119
|
+
const keyName = providerType === 'google' ? 'GEMINI_API_KEY' :
|
|
120
|
+
providerType === 'anthropic' ? 'ANTHROPIC_API_KEY' : 'OPENAI_API_KEY';
|
|
121
|
+
throw new Error(`${providerType} API key is required. Provide it via options.apiKey or ${keyName} environment variable.`);
|
|
122
|
+
}
|
|
123
|
+
// Create provider
|
|
124
|
+
let provider;
|
|
125
|
+
if (providerType === 'google') {
|
|
126
|
+
provider = new GoogleProvider({ apiKey, model: options.model });
|
|
127
|
+
}
|
|
128
|
+
else if (providerType === 'anthropic') {
|
|
129
|
+
provider = new AnthropicProvider({ apiKey, model: options.model });
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
provider = new OpenAIProvider({ apiKey, model: options.model, baseURL: options.baseURL });
|
|
133
|
+
}
|
|
134
|
+
// Create tool registry with default tools
|
|
135
|
+
const toolRegistry = createDefaultRegistry();
|
|
136
|
+
// Create ReAct loop
|
|
137
|
+
const loop = new ReActLoop(provider, toolRegistry, {
|
|
138
|
+
maxTurns: options.maxTurns ?? 10,
|
|
139
|
+
systemPrompt: options.systemPrompt,
|
|
140
|
+
allowedTools: options.allowedTools,
|
|
141
|
+
cwd: options.cwd,
|
|
142
|
+
env: options.env,
|
|
143
|
+
abortController: options.abortController,
|
|
144
|
+
permissionMode: options.permissionMode,
|
|
145
|
+
mcpServers: options.mcpServers,
|
|
146
|
+
canUseTool: options.canUseTool,
|
|
147
|
+
});
|
|
148
|
+
// Run the loop
|
|
149
|
+
const result = await loop.run(prompt);
|
|
150
|
+
const duration_ms = Date.now() - startTime;
|
|
151
|
+
// If storage is provided, create and save a session
|
|
152
|
+
if (storage) {
|
|
153
|
+
session = await createSession({
|
|
154
|
+
model: options.model,
|
|
155
|
+
provider: options.provider,
|
|
156
|
+
apiKey: options.apiKey,
|
|
157
|
+
storage,
|
|
158
|
+
logLevel,
|
|
159
|
+
maxTurns: options.maxTurns,
|
|
160
|
+
allowedTools: options.allowedTools,
|
|
161
|
+
systemPrompt: options.systemPrompt,
|
|
162
|
+
cwd: options.cwd,
|
|
163
|
+
env: options.env,
|
|
164
|
+
permissionMode: options.permissionMode,
|
|
165
|
+
allowDangerouslySkipPermissions: options.allowDangerouslySkipPermissions,
|
|
166
|
+
canUseTool: options.canUseTool,
|
|
167
|
+
mcpServers: options.mcpServers,
|
|
168
|
+
});
|
|
169
|
+
sessionId = session.id;
|
|
170
|
+
// Send the prompt and stream to populate the session
|
|
171
|
+
await session.send(prompt);
|
|
172
|
+
// Collect messages to populate session history
|
|
173
|
+
for await (const _message of session.stream()) {
|
|
174
|
+
// Just consume the stream to populate session messages
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
result: result.result,
|
|
179
|
+
duration_ms,
|
|
180
|
+
usage: result.usage,
|
|
181
|
+
session_id: sessionId,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Estimate token count from text (rough approximation)
|
|
186
|
+
* @param text - Text to estimate tokens for
|
|
187
|
+
* @returns Estimated token count
|
|
188
|
+
*/
|
|
189
|
+
function estimateTokens(text) {
|
|
190
|
+
// Rough approximation: ~4 characters per token on average
|
|
191
|
+
return Math.ceil(text.length / 4);
|
|
192
|
+
}
|
|
193
|
+
// Re-export providers
|
|
194
|
+
export { LLMProvider } from './providers/base';
|
|
195
|
+
export { OpenAIProvider } from './providers/openai';
|
|
196
|
+
export { GoogleProvider } from './providers/google';
|
|
197
|
+
export { AnthropicProvider } from './providers/anthropic';
|
|
198
|
+
// Re-export tools
|
|
199
|
+
export { ToolRegistry, createDefaultRegistry, ReadTool, readTool, WriteTool, writeTool, EditTool, editTool, BashTool, bashTool, GlobTool, globTool, GrepTool, grepTool, TaskListTool, taskListTool, TaskCreateTool, taskCreateTool, TaskGetTool, taskGetTool, TaskUpdateTool, taskUpdateTool, WebSearchTool, webSearchTool, WebFetchTool, webFetchTool, BashOutputTool, bashOutputTool, KillBashTool, killBashTool, AskUserQuestionTool, askUserQuestionTool, } from './tools/registry';
|
|
200
|
+
// Re-export agent
|
|
201
|
+
export { ReActLoop } from './agent/react-loop';
|
|
202
|
+
// Re-export agent definitions
|
|
203
|
+
export { AgentDefinitionSchema, validateAgentDefinition, safeValidateAgentDefinition, createAgentDefinition, hasCustomTools, inheritsModel, hasCustomMaxTurns, hasCustomPermissionMode, } from './agent/agent-definition';
|
|
204
|
+
// Re-export subagent runner
|
|
205
|
+
export { runSubagent, isSubagentSuccess, formatSubagentResult, } from './agent/subagent-runner';
|
|
206
|
+
// Re-export task tool
|
|
207
|
+
export { TaskTool, createTaskTool, createTaskToolFromConfig } from './tools/task';
|
|
208
|
+
// Re-export message helpers
|
|
209
|
+
export { createUserMessage, createSystemMessage, createAssistantMessage, createToolResultMessage, createResultMessage, createCompactBoundaryMessage, } from './types/messages';
|
|
210
|
+
// Re-export session
|
|
211
|
+
export { Session, SessionState, SessionError, SessionNotIdleError, SessionNotReadyError, SessionAlreadyStreamingError, SessionClosedError, InMemoryStorage, FileStorage, createSession, resumeSession, forkSession, } from './session';
|
|
212
|
+
// Re-export logger
|
|
213
|
+
export { logger } from './utils/logger';
|
|
214
|
+
// Re-export hooks
|
|
215
|
+
export { HookManager, createPreToolUseInput, createPostToolUseInput, createSessionStartInput, createSessionEndInput, createSubagentStartInput, createSubagentStopInput, createNotificationInput, createStopInput, createPreCompactInput, createUserPromptSubmitInput, } from './hooks';
|
|
216
|
+
// Re-export MCP module
|
|
217
|
+
export * from './mcp';
|
|
218
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AAGvD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC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YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,kBAAkB,EAClB,eAAe,EACf,WAAW,EACX,aAAa,EACb,aAAa,EACb,WAAW,GAQZ,MAAM,WAAW,CAAC;AAEnB,mBAAmB;AACnB,OAAO,EAAE,MAAM,EAAiB,MAAM,gBAAgB,CAAC;AAEvD,kBAAkB;AAClB,OAAO,EACL,WAAW,EAqBX,qBAAqB,EACrB,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,EACxB,uBAAuB,EACvB,uBAAuB,EACvB,eAAe,EACf,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,SAAS,CAAC;AAEjB,uBAAuB;AACvB,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) error classes
|
|
3
|
+
*/
|
|
4
|
+
/** Base MCP error */
|
|
5
|
+
export declare class MCPError extends Error {
|
|
6
|
+
code: string;
|
|
7
|
+
constructor(message: string, code: string);
|
|
8
|
+
}
|
|
9
|
+
/** Connection error */
|
|
10
|
+
export declare class MCPConnectionError extends MCPError {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/** Timeout error */
|
|
14
|
+
export declare class MCPTimeoutError extends MCPError {
|
|
15
|
+
constructor(message: string);
|
|
16
|
+
}
|
|
17
|
+
/** Protocol error */
|
|
18
|
+
export declare class MCPProtocolError extends MCPError {
|
|
19
|
+
constructor(message: string);
|
|
20
|
+
}
|
|
21
|
+
/** Tool execution error */
|
|
22
|
+
export declare class MCPToolError extends MCPError {
|
|
23
|
+
toolName: string;
|
|
24
|
+
constructor(message: string, toolName: string);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/mcp/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAqB;AACrB,qBAAa,QAAS,SAAQ,KAAK;IAGxB,IAAI,EAAE,MAAM;gBADnB,OAAO,EAAE,MAAM,EACR,IAAI,EAAE,MAAM;CAKtB;AAED,uBAAuB;AACvB,qBAAa,kBAAmB,SAAQ,QAAQ;gBAClC,OAAO,EAAE,MAAM;CAI5B;AAED,oBAAoB;AACpB,qBAAa,eAAgB,SAAQ,QAAQ;gBAC/B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAqB;AACrB,qBAAa,gBAAiB,SAAQ,QAAQ;gBAChC,OAAO,EAAE,MAAM;CAI5B;AAED,2BAA2B;AAC3B,qBAAa,YAAa,SAAQ,QAAQ;IAG/B,QAAQ,EAAE,MAAM;gBADvB,OAAO,EAAE,MAAM,EACR,QAAQ,EAAE,MAAM;CAK1B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) error classes
|
|
3
|
+
*/
|
|
4
|
+
/** Base MCP error */
|
|
5
|
+
export class MCPError extends Error {
|
|
6
|
+
code;
|
|
7
|
+
constructor(message, code) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.code = code;
|
|
10
|
+
this.name = 'MCPError';
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Connection error */
|
|
14
|
+
export class MCPConnectionError extends MCPError {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message, 'CONNECTION_ERROR');
|
|
17
|
+
this.name = 'MCPConnectionError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Timeout error */
|
|
21
|
+
export class MCPTimeoutError extends MCPError {
|
|
22
|
+
constructor(message) {
|
|
23
|
+
super(message, 'TIMEOUT_ERROR');
|
|
24
|
+
this.name = 'MCPTimeoutError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Protocol error */
|
|
28
|
+
export class MCPProtocolError extends MCPError {
|
|
29
|
+
constructor(message) {
|
|
30
|
+
super(message, 'PROTOCOL_ERROR');
|
|
31
|
+
this.name = 'MCPProtocolError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** Tool execution error */
|
|
35
|
+
export class MCPToolError extends MCPError {
|
|
36
|
+
toolName;
|
|
37
|
+
constructor(message, toolName) {
|
|
38
|
+
super(message, 'TOOL_ERROR');
|
|
39
|
+
this.toolName = toolName;
|
|
40
|
+
this.name = 'MCPToolError';
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/mcp/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAqB;AACrB,MAAM,OAAO,QAAS,SAAQ,KAAK;IAGxB;IAFT,YACE,OAAe,EACR,IAAY;QAEnB,KAAK,CAAC,OAAO,CAAC,CAAC;QAFR,SAAI,GAAJ,IAAI,CAAQ;QAGnB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED,uBAAuB;AACvB,MAAM,OAAO,kBAAmB,SAAQ,QAAQ;IAC9C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,oBAAoB;AACpB,MAAM,OAAO,eAAgB,SAAQ,QAAQ;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,qBAAqB;AACrB,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IAC5C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED,2BAA2B;AAC3B,MAAM,OAAO,YAAa,SAAQ,QAAQ;IAG/B;IAFT,YACE,OAAe,EACR,QAAgB;QAEvB,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;QAFtB,aAAQ,GAAR,QAAQ,CAAQ;QAGvB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) module
|
|
3
|
+
* Exports all MCP-related types and classes
|
|
4
|
+
*/
|
|
5
|
+
export type { McpServerConfig, McpServersConfig, McpStdioServerConfig, McpHttpServerConfig, McpSSEServerConfig, McpSdkServerConfig, McpServerStatus, McpTool, McpToolResult, } from './types.js';
|
|
6
|
+
export { isStdioConfig, isHttpConfig, isSseConfig, isSdkConfig, } from './types.js';
|
|
7
|
+
export { McpManager } from './manager.js';
|
|
8
|
+
export { McpToolAdapter } from './tool-adapter.js';
|
|
9
|
+
export { McpServerRegistry } from './server-registry.js';
|
|
10
|
+
export { MCPError, MCPConnectionError, MCPTimeoutError, MCPProtocolError, MCPToolError, } from './errors.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EACV,eAAe,EACf,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,OAAO,EACP,aAAa,GACd,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,aAAa,EACb,YAAY,EACZ,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAGzD,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,YAAY,GACb,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP (Model Context Protocol) module
|
|
3
|
+
* Exports all MCP-related types and classes
|
|
4
|
+
*/
|
|
5
|
+
// Type guards
|
|
6
|
+
export { isStdioConfig, isHttpConfig, isSseConfig, isSdkConfig, } from './types.js';
|
|
7
|
+
// Classes
|
|
8
|
+
export { McpManager } from './manager.js';
|
|
9
|
+
export { McpToolAdapter } from './tool-adapter.js';
|
|
10
|
+
export { McpServerRegistry } from './server-registry.js';
|
|
11
|
+
// Errors
|
|
12
|
+
export { MCPError, MCPConnectionError, MCPTimeoutError, MCPProtocolError, MCPToolError, } from './errors.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/mcp/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,cAAc;AACd,OAAO,EACL,aAAa,EACb,YAAY,EACZ,WAAW,EACX,WAAW,GACZ,MAAM,YAAY,CAAC;AAEpB,UAAU;AACV,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,SAAS;AACT,OAAO,EACL,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,YAAY,GACb,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Manager
|
|
3
|
+
* Wraps the official MCP SDK to manage multiple server connections
|
|
4
|
+
*/
|
|
5
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import type { McpServerConfig, McpServerStatus, McpTool, McpToolResult } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Manages multiple MCP server connections
|
|
9
|
+
* Wraps the official MCP SDK Client and Transport classes
|
|
10
|
+
*/
|
|
11
|
+
export declare class McpManager {
|
|
12
|
+
private clients;
|
|
13
|
+
private transports;
|
|
14
|
+
private statuses;
|
|
15
|
+
/**
|
|
16
|
+
* Connect to an MCP server
|
|
17
|
+
* Creates appropriate Transport and Client based on config type
|
|
18
|
+
*/
|
|
19
|
+
connect(name: string, config: McpServerConfig): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Disconnect all MCP servers
|
|
22
|
+
*/
|
|
23
|
+
disconnect(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Get a client by server name
|
|
26
|
+
*/
|
|
27
|
+
getClient(name: string): Client | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Get all server statuses
|
|
30
|
+
*/
|
|
31
|
+
getAllStatuses(): McpServerStatus[];
|
|
32
|
+
/**
|
|
33
|
+
* Get status for a specific server
|
|
34
|
+
*/
|
|
35
|
+
getStatus(name: string): McpServerStatus | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* List tools from all connected servers
|
|
38
|
+
* Returns a map of server name to tool list
|
|
39
|
+
*/
|
|
40
|
+
listAllTools(): Promise<Map<string, McpTool[]>>;
|
|
41
|
+
/**
|
|
42
|
+
* Call a tool on a specific server
|
|
43
|
+
*/
|
|
44
|
+
callTool(serverName: string, toolName: string, args: unknown): Promise<McpToolResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Get all connected clients
|
|
47
|
+
*/
|
|
48
|
+
getClients(): Map<string, Client>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/mcp/manager.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAGnE,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,OAAO,EACP,aAAa,EACd,MAAM,YAAY,CAAC;AAIpB;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,UAAU,CAA2E;IAC7F,OAAO,CAAC,QAAQ,CAAsC;IAEtD;;;OAGG;IACG,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgFnE;;OAEG;IACG,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAcjC;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI3C;;OAEG;IACH,cAAc,IAAI,eAAe,EAAE;IAInC;;OAEG;IACH,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS;IAIpD;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC,CAAC;IAgBrD;;OAEG;IACG,QAAQ,CACZ,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,aAAa,CAAC;IAezB;;OAEG;IACH,UAAU,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC;CAGlC"}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Manager
|
|
3
|
+
* Wraps the official MCP SDK to manage multiple server connections
|
|
4
|
+
*/
|
|
5
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';
|
|
7
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
8
|
+
import { isStdioConfig, isHttpConfig, isSseConfig, isSdkConfig } from './types.js';
|
|
9
|
+
import { MCPConnectionError } from './errors.js';
|
|
10
|
+
/**
|
|
11
|
+
* Manages multiple MCP server connections
|
|
12
|
+
* Wraps the official MCP SDK Client and Transport classes
|
|
13
|
+
*/
|
|
14
|
+
export class McpManager {
|
|
15
|
+
clients = new Map();
|
|
16
|
+
transports = new Map();
|
|
17
|
+
statuses = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* Connect to an MCP server
|
|
20
|
+
* Creates appropriate Transport and Client based on config type
|
|
21
|
+
*/
|
|
22
|
+
async connect(name, config) {
|
|
23
|
+
// Initialize status as pending
|
|
24
|
+
this.statuses.set(name, {
|
|
25
|
+
name,
|
|
26
|
+
status: 'pending',
|
|
27
|
+
tools: [],
|
|
28
|
+
});
|
|
29
|
+
try {
|
|
30
|
+
let transport;
|
|
31
|
+
if (isStdioConfig(config)) {
|
|
32
|
+
transport = new StdioClientTransport({
|
|
33
|
+
command: config.command,
|
|
34
|
+
args: config.args,
|
|
35
|
+
env: config.env,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else if (isHttpConfig(config)) {
|
|
39
|
+
// StreamableHTTPClientTransport options may vary by SDK version
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
const httpOptions = {};
|
|
42
|
+
if (config.headers) {
|
|
43
|
+
httpOptions.headers = config.headers;
|
|
44
|
+
}
|
|
45
|
+
transport = new StreamableHTTPClientTransport(new URL(config.url), httpOptions);
|
|
46
|
+
}
|
|
47
|
+
else if (isSseConfig(config)) {
|
|
48
|
+
throw new Error('SSE transport not yet implemented');
|
|
49
|
+
}
|
|
50
|
+
else if (isSdkConfig(config)) {
|
|
51
|
+
throw new Error('SDK transport not yet implemented');
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
throw new Error(`Unknown MCP config type: ${config.type}`);
|
|
55
|
+
}
|
|
56
|
+
const client = new Client({
|
|
57
|
+
name: 'open-agent-sdk',
|
|
58
|
+
version: '0.1.0',
|
|
59
|
+
});
|
|
60
|
+
await client.connect(transport);
|
|
61
|
+
// Store client and transport
|
|
62
|
+
this.clients.set(name, client);
|
|
63
|
+
this.transports.set(name, transport);
|
|
64
|
+
// Update status to connected
|
|
65
|
+
this.statuses.set(name, {
|
|
66
|
+
name,
|
|
67
|
+
status: 'connected',
|
|
68
|
+
tools: [],
|
|
69
|
+
});
|
|
70
|
+
// Fetch and store tools list
|
|
71
|
+
try {
|
|
72
|
+
const toolsResponse = await client.listTools();
|
|
73
|
+
const tools = toolsResponse.tools.map((t) => t.name);
|
|
74
|
+
this.statuses.set(name, {
|
|
75
|
+
name,
|
|
76
|
+
status: 'connected',
|
|
77
|
+
tools,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
// Tools list not critical, just log
|
|
82
|
+
console.warn(`Failed to list tools for MCP server "${name}":`, error);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
// Update status to failed
|
|
87
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
88
|
+
this.statuses.set(name, {
|
|
89
|
+
name,
|
|
90
|
+
status: 'failed',
|
|
91
|
+
tools: [],
|
|
92
|
+
error: errorMessage,
|
|
93
|
+
});
|
|
94
|
+
throw new MCPConnectionError(`Failed to connect to MCP server "${name}": ${errorMessage}`);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Disconnect all MCP servers
|
|
99
|
+
*/
|
|
100
|
+
async disconnect() {
|
|
101
|
+
for (const [name, client] of this.clients) {
|
|
102
|
+
try {
|
|
103
|
+
await client.close();
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
console.warn(`Error closing MCP client "${name}":`, error);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
this.clients.clear();
|
|
110
|
+
this.transports.clear();
|
|
111
|
+
// Keep statuses for reference
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Get a client by server name
|
|
115
|
+
*/
|
|
116
|
+
getClient(name) {
|
|
117
|
+
return this.clients.get(name);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Get all server statuses
|
|
121
|
+
*/
|
|
122
|
+
getAllStatuses() {
|
|
123
|
+
return Array.from(this.statuses.values());
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Get status for a specific server
|
|
127
|
+
*/
|
|
128
|
+
getStatus(name) {
|
|
129
|
+
return this.statuses.get(name);
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* List tools from all connected servers
|
|
133
|
+
* Returns a map of server name to tool list
|
|
134
|
+
*/
|
|
135
|
+
async listAllTools() {
|
|
136
|
+
const result = new Map();
|
|
137
|
+
for (const [name, client] of this.clients) {
|
|
138
|
+
try {
|
|
139
|
+
const response = await client.listTools();
|
|
140
|
+
result.set(name, response.tools);
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.warn(`Failed to list tools for server "${name}":`, error);
|
|
144
|
+
result.set(name, []);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Call a tool on a specific server
|
|
151
|
+
*/
|
|
152
|
+
async callTool(serverName, toolName, args) {
|
|
153
|
+
const client = this.clients.get(serverName);
|
|
154
|
+
if (!client) {
|
|
155
|
+
throw new Error(`MCP server "${serverName}" not found`);
|
|
156
|
+
}
|
|
157
|
+
const result = await client.callTool({
|
|
158
|
+
name: toolName,
|
|
159
|
+
arguments: args,
|
|
160
|
+
});
|
|
161
|
+
return result;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Get all connected clients
|
|
165
|
+
*/
|
|
166
|
+
getClients() {
|
|
167
|
+
return new Map(this.clients);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
//# sourceMappingURL=manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"man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AG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;CACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Server Registry
|
|
3
|
+
* Manages registration of MCP tools to SDK ToolRegistry
|
|
4
|
+
*/
|
|
5
|
+
import type { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
6
|
+
import type { ToolRegistry } from '../tools/registry.js';
|
|
7
|
+
/**
|
|
8
|
+
* Manages registration of MCP server tools to SDK ToolRegistry
|
|
9
|
+
*/
|
|
10
|
+
export declare class McpServerRegistry {
|
|
11
|
+
private toolRegistry;
|
|
12
|
+
private registeredTools;
|
|
13
|
+
constructor(toolRegistry: ToolRegistry);
|
|
14
|
+
/**
|
|
15
|
+
* Register all tools from an MCP server
|
|
16
|
+
* Returns list of registered tool names (with prefixes)
|
|
17
|
+
*/
|
|
18
|
+
registerServer(name: string, client: Client): Promise<string[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Unregister all tools from a server
|
|
21
|
+
*/
|
|
22
|
+
unregisterServer(name: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Check if a tool name is an MCP tool
|
|
25
|
+
*/
|
|
26
|
+
isMcpTool(toolName: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Parse MCP tool name to extract server and tool name
|
|
29
|
+
* Format: mcp_<server>_<tool>
|
|
30
|
+
*/
|
|
31
|
+
parseMcpToolName(prefixedName: string): {
|
|
32
|
+
serverName: string;
|
|
33
|
+
toolName: string;
|
|
34
|
+
} | null;
|
|
35
|
+
/**
|
|
36
|
+
* Get server name for a registered MCP tool
|
|
37
|
+
*/
|
|
38
|
+
getServerForTool(toolName: string): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Get all registered server names
|
|
41
|
+
*/
|
|
42
|
+
getRegisteredServers(): string[];
|
|
43
|
+
/**
|
|
44
|
+
* Get tools registered for a specific server
|
|
45
|
+
*/
|
|
46
|
+
getServerTools(serverName: string): string[];
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=server-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-registry.d.ts","sourceRoot":"","sources":["../../src/mcp/server-registry.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACxE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIzD;;GAEG;AACH,qBAAa,iBAAiB;IAGhB,OAAO,CAAC,YAAY;IAFhC,OAAO,CAAC,eAAe,CAAkC;gBAErC,YAAY,EAAE,YAAY;IAE9C;;;OAGG;IACG,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAkCrE;;OAEG;IACH,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAgBpC;;OAEG;IACH,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAUpC;;;OAGG;IACH,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAqBvF;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAejD;;OAEG;IACH,oBAAoB,IAAI,MAAM,EAAE;IAIhC;;OAEG;IACH,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE;CAI7C"}
|