@cogitator-ai/mcp 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 +81 -0
- package/dist/adapter/tool-adapter.d.ts +85 -0
- package/dist/adapter/tool-adapter.d.ts.map +1 -0
- package/dist/adapter/tool-adapter.js +239 -0
- package/dist/adapter/tool-adapter.js.map +1 -0
- package/dist/client/mcp-client.d.ts +117 -0
- package/dist/client/mcp-client.d.ts.map +1 -0
- package/dist/client/mcp-client.js +276 -0
- package/dist/client/mcp-client.js.map +1 -0
- package/dist/client/transports.d.ts +46 -0
- package/dist/client/transports.d.ts.map +1 -0
- package/dist/client/transports.js +49 -0
- package/dist/client/transports.js.map +1 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/server/mcp-server.d.ts +94 -0
- package/dist/server/mcp-server.d.ts.map +1 -0
- package/dist/server/mcp-server.js +250 -0
- package/dist/server/mcp-server.js.map +1 -0
- package/dist/types.d.ts +111 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +5 -0
- package/dist/types.js.map +1 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Cogitator Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# @cogitator-ai/mcp
|
|
2
|
+
|
|
3
|
+
MCP (Model Context Protocol) integration for Cogitator. Connect to external MCP servers or expose Cogitator tools as an MCP server.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @cogitator-ai/mcp
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### MCP Client
|
|
14
|
+
|
|
15
|
+
Connect to external MCP servers:
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { MCPClient } from '@cogitator-ai/mcp';
|
|
19
|
+
|
|
20
|
+
const client = new MCPClient({
|
|
21
|
+
transport: 'stdio',
|
|
22
|
+
command: 'npx',
|
|
23
|
+
args: ['-y', '@anthropic/mcp-server-filesystem'],
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
await client.connect();
|
|
27
|
+
|
|
28
|
+
// List available tools
|
|
29
|
+
const tools = await client.listTools();
|
|
30
|
+
|
|
31
|
+
// Execute a tool
|
|
32
|
+
const result = await client.executeTool('read_file', {
|
|
33
|
+
path: '/path/to/file.txt',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Get tools as Cogitator tools
|
|
37
|
+
const cogitatorTools = client.asCogitatorTools();
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### MCP Server
|
|
41
|
+
|
|
42
|
+
Expose Cogitator tools as an MCP server:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { MCPServer } from '@cogitator-ai/mcp';
|
|
46
|
+
import { builtinTools } from '@cogitator-ai/core';
|
|
47
|
+
|
|
48
|
+
const server = new MCPServer({
|
|
49
|
+
name: 'cogitator-tools',
|
|
50
|
+
version: '1.0.0',
|
|
51
|
+
tools: builtinTools,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// Start stdio server
|
|
55
|
+
await server.start('stdio');
|
|
56
|
+
|
|
57
|
+
// Or HTTP server
|
|
58
|
+
await server.start('http', { port: 3001 });
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Tool Adapter
|
|
62
|
+
|
|
63
|
+
Convert between Cogitator and MCP tool formats:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { toMCPTool, toCogitatorTool } from '@cogitator-ai/mcp';
|
|
67
|
+
|
|
68
|
+
// Cogitator → MCP
|
|
69
|
+
const mcpTool = toMCPTool(cogitatorTool);
|
|
70
|
+
|
|
71
|
+
// MCP → Cogitator
|
|
72
|
+
const cogitatorTool = toCogitatorTool(mcpTool);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Documentation
|
|
76
|
+
|
|
77
|
+
See the [Cogitator documentation](https://github.com/eL1fe/cogitator) for full API reference.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Adapter
|
|
3
|
+
*
|
|
4
|
+
* Converts between Cogitator Tool format and MCP Tool format.
|
|
5
|
+
* Enables bidirectional interoperability.
|
|
6
|
+
*/
|
|
7
|
+
import { type ZodTypeAny, type ZodObject, type ZodRawShape } from 'zod';
|
|
8
|
+
import type { Tool, ToolSchema } from '@cogitator-ai/types';
|
|
9
|
+
import type { MCPToolDefinition, MCPToolContent, ToolAdapterOptions } from '../types';
|
|
10
|
+
import type { MCPClient } from '../client/mcp-client';
|
|
11
|
+
/**
|
|
12
|
+
* Convert a Zod schema to JSON Schema
|
|
13
|
+
*/
|
|
14
|
+
export declare function zodToJsonSchema(schema: ZodTypeAny): {
|
|
15
|
+
type: 'object';
|
|
16
|
+
properties: Record<string, unknown>;
|
|
17
|
+
required?: string[];
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Convert JSON Schema to a Zod schema
|
|
21
|
+
*
|
|
22
|
+
* Note: This is a simplified conversion that handles common cases.
|
|
23
|
+
* Complex schemas may need manual adjustment.
|
|
24
|
+
*/
|
|
25
|
+
export declare function jsonSchemaToZod(schema: {
|
|
26
|
+
type: string;
|
|
27
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
28
|
+
required?: string[];
|
|
29
|
+
}): ZodObject<ZodRawShape>;
|
|
30
|
+
interface JsonSchemaProperty {
|
|
31
|
+
type?: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
enum?: unknown[];
|
|
34
|
+
items?: JsonSchemaProperty;
|
|
35
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
36
|
+
required?: string[];
|
|
37
|
+
default?: unknown;
|
|
38
|
+
minimum?: number;
|
|
39
|
+
maximum?: number;
|
|
40
|
+
minLength?: number;
|
|
41
|
+
maxLength?: number;
|
|
42
|
+
pattern?: string;
|
|
43
|
+
format?: string;
|
|
44
|
+
oneOf?: JsonSchemaProperty[];
|
|
45
|
+
anyOf?: JsonSchemaProperty[];
|
|
46
|
+
allOf?: JsonSchemaProperty[];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Convert a Cogitator Tool to MCP tool definition format
|
|
50
|
+
*/
|
|
51
|
+
export declare function cogitatorToMCP(tool: Tool): MCPToolDefinition;
|
|
52
|
+
/**
|
|
53
|
+
* Convert a Cogitator ToolSchema to MCP tool definition format
|
|
54
|
+
*/
|
|
55
|
+
export declare function toolSchemaToMCP(schema: ToolSchema): MCPToolDefinition;
|
|
56
|
+
/**
|
|
57
|
+
* Convert an MCP tool definition to a Cogitator Tool
|
|
58
|
+
*
|
|
59
|
+
* The resulting tool will execute calls through the provided MCPClient.
|
|
60
|
+
*/
|
|
61
|
+
export declare function mcpToCogitator(mcpTool: MCPToolDefinition, client: MCPClient, options?: ToolAdapterOptions): Tool;
|
|
62
|
+
/**
|
|
63
|
+
* Wrap all tools from an MCP client as Cogitator tools
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```typescript
|
|
67
|
+
* const client = await MCPClient.connect({ ... });
|
|
68
|
+
* const tools = await wrapMCPTools(client);
|
|
69
|
+
*
|
|
70
|
+
* const agent = new Agent({
|
|
71
|
+
* tools: [...tools, ...otherTools],
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function wrapMCPTools(client: MCPClient, options?: ToolAdapterOptions): Promise<Tool[]>;
|
|
76
|
+
/**
|
|
77
|
+
* Convert a tool execution result to MCP content format
|
|
78
|
+
*/
|
|
79
|
+
export declare function resultToMCPContent(result: unknown): MCPToolContent[];
|
|
80
|
+
/**
|
|
81
|
+
* Convert MCP content to a simple result value
|
|
82
|
+
*/
|
|
83
|
+
export declare function mcpContentToResult(content: MCPToolContent[]): unknown;
|
|
84
|
+
export {};
|
|
85
|
+
//# sourceMappingURL=tool-adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-adapter.d.ts","sourceRoot":"","sources":["../../src/adapter/tool-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAK,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAE3E,OAAO,KAAK,EAAE,IAAI,EAAE,UAAU,EAAe,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AC;IAC7B,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAC;CAC9B;AA4ED;;GAEG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,IAAI,GAAG,iBAAiB,CAY5D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,iBAAiB,CAUrE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,IAAI,CAmCN;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,SAAS,EACjB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,IAAI,EAAE,CAAC,CAGjB;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,OAAO,GAAG,cAAc,EAAE,CAqBpE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,OAAO,CAwBrE"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Adapter
|
|
3
|
+
*
|
|
4
|
+
* Converts between Cogitator Tool format and MCP Tool format.
|
|
5
|
+
* Enables bidirectional interoperability.
|
|
6
|
+
*/
|
|
7
|
+
import { z } from 'zod';
|
|
8
|
+
import { zodToJsonSchema as zodToJsonSchemaLib } from 'zod-to-json-schema';
|
|
9
|
+
/**
|
|
10
|
+
* Convert a Zod schema to JSON Schema
|
|
11
|
+
*/
|
|
12
|
+
export function zodToJsonSchema(schema) {
|
|
13
|
+
const jsonSchema = zodToJsonSchemaLib(schema, {
|
|
14
|
+
$refStrategy: 'none',
|
|
15
|
+
target: 'openApi3',
|
|
16
|
+
});
|
|
17
|
+
const result = jsonSchema;
|
|
18
|
+
delete result.$schema;
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Convert JSON Schema to a Zod schema
|
|
23
|
+
*
|
|
24
|
+
* Note: This is a simplified conversion that handles common cases.
|
|
25
|
+
* Complex schemas may need manual adjustment.
|
|
26
|
+
*/
|
|
27
|
+
export function jsonSchemaToZod(schema) {
|
|
28
|
+
if (schema.type !== 'object' || !schema.properties) {
|
|
29
|
+
return z.object({});
|
|
30
|
+
}
|
|
31
|
+
const shape = {};
|
|
32
|
+
const required = new Set(schema.required ?? []);
|
|
33
|
+
for (const [key, prop] of Object.entries(schema.properties)) {
|
|
34
|
+
let zodType = jsonSchemaPropertyToZod(prop);
|
|
35
|
+
if (prop.description) {
|
|
36
|
+
zodType = zodType.describe(prop.description);
|
|
37
|
+
}
|
|
38
|
+
if (!required.has(key)) {
|
|
39
|
+
zodType = zodType.optional();
|
|
40
|
+
}
|
|
41
|
+
shape[key] = zodType;
|
|
42
|
+
}
|
|
43
|
+
return z.object(shape);
|
|
44
|
+
}
|
|
45
|
+
function jsonSchemaPropertyToZod(prop) {
|
|
46
|
+
if (prop.enum && Array.isArray(prop.enum)) {
|
|
47
|
+
if (prop.enum.length >= 2 && prop.enum.every((v) => typeof v === 'string')) {
|
|
48
|
+
return z.enum(prop.enum);
|
|
49
|
+
}
|
|
50
|
+
if (prop.enum.length >= 2) {
|
|
51
|
+
const literals = prop.enum.map((v) => z.literal(v));
|
|
52
|
+
return z.union([literals[0], literals[1], ...literals.slice(2)]);
|
|
53
|
+
}
|
|
54
|
+
if (prop.enum.length === 1) {
|
|
55
|
+
return z.literal(prop.enum[0]);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
switch (prop.type) {
|
|
59
|
+
case 'string': {
|
|
60
|
+
let schema = z.string();
|
|
61
|
+
if (prop.minLength !== undefined) {
|
|
62
|
+
schema = schema.min(prop.minLength);
|
|
63
|
+
}
|
|
64
|
+
if (prop.maxLength !== undefined) {
|
|
65
|
+
schema = schema.max(prop.maxLength);
|
|
66
|
+
}
|
|
67
|
+
if (prop.pattern) {
|
|
68
|
+
schema = schema.regex(new RegExp(prop.pattern));
|
|
69
|
+
}
|
|
70
|
+
if (prop.format === 'email') {
|
|
71
|
+
schema = schema.email();
|
|
72
|
+
}
|
|
73
|
+
if (prop.format === 'uri' || prop.format === 'url') {
|
|
74
|
+
schema = schema.url();
|
|
75
|
+
}
|
|
76
|
+
return schema;
|
|
77
|
+
}
|
|
78
|
+
case 'number':
|
|
79
|
+
case 'integer': {
|
|
80
|
+
let schema = prop.type === 'integer' ? z.number().int() : z.number();
|
|
81
|
+
if (prop.minimum !== undefined) {
|
|
82
|
+
schema = schema.min(prop.minimum);
|
|
83
|
+
}
|
|
84
|
+
if (prop.maximum !== undefined) {
|
|
85
|
+
schema = schema.max(prop.maximum);
|
|
86
|
+
}
|
|
87
|
+
return schema;
|
|
88
|
+
}
|
|
89
|
+
case 'boolean':
|
|
90
|
+
return z.boolean();
|
|
91
|
+
case 'array': {
|
|
92
|
+
const itemSchema = prop.items ? jsonSchemaPropertyToZod(prop.items) : z.unknown();
|
|
93
|
+
return z.array(itemSchema);
|
|
94
|
+
}
|
|
95
|
+
case 'object': {
|
|
96
|
+
if (prop.properties) {
|
|
97
|
+
return jsonSchemaToZod({
|
|
98
|
+
type: 'object',
|
|
99
|
+
properties: prop.properties,
|
|
100
|
+
required: prop.required,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return z.record(z.unknown());
|
|
104
|
+
}
|
|
105
|
+
case 'null':
|
|
106
|
+
return z.null();
|
|
107
|
+
default:
|
|
108
|
+
return z.unknown();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Convert a Cogitator Tool to MCP tool definition format
|
|
113
|
+
*/
|
|
114
|
+
export function cogitatorToMCP(tool) {
|
|
115
|
+
const schema = tool.toJSON();
|
|
116
|
+
return {
|
|
117
|
+
name: schema.name,
|
|
118
|
+
description: schema.description,
|
|
119
|
+
inputSchema: {
|
|
120
|
+
type: 'object',
|
|
121
|
+
properties: schema.parameters.properties,
|
|
122
|
+
required: schema.parameters.required,
|
|
123
|
+
},
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Convert a Cogitator ToolSchema to MCP tool definition format
|
|
128
|
+
*/
|
|
129
|
+
export function toolSchemaToMCP(schema) {
|
|
130
|
+
return {
|
|
131
|
+
name: schema.name,
|
|
132
|
+
description: schema.description,
|
|
133
|
+
inputSchema: {
|
|
134
|
+
type: 'object',
|
|
135
|
+
properties: schema.parameters.properties,
|
|
136
|
+
required: schema.parameters.required,
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Convert an MCP tool definition to a Cogitator Tool
|
|
142
|
+
*
|
|
143
|
+
* The resulting tool will execute calls through the provided MCPClient.
|
|
144
|
+
*/
|
|
145
|
+
export function mcpToCogitator(mcpTool, client, options) {
|
|
146
|
+
const name = options?.namePrefix ? `${options.namePrefix}${mcpTool.name}` : mcpTool.name;
|
|
147
|
+
const description = options?.descriptionTransform
|
|
148
|
+
? options.descriptionTransform(mcpTool.description)
|
|
149
|
+
: mcpTool.description;
|
|
150
|
+
const inputSchema = {
|
|
151
|
+
type: 'object',
|
|
152
|
+
properties: mcpTool.inputSchema.properties,
|
|
153
|
+
required: mcpTool.inputSchema.required,
|
|
154
|
+
};
|
|
155
|
+
const parameters = jsonSchemaToZod(inputSchema);
|
|
156
|
+
const tool = {
|
|
157
|
+
name,
|
|
158
|
+
description,
|
|
159
|
+
parameters,
|
|
160
|
+
execute: async (params, _context) => {
|
|
161
|
+
return client.callTool(mcpTool.name, params);
|
|
162
|
+
},
|
|
163
|
+
toJSON: () => ({
|
|
164
|
+
name,
|
|
165
|
+
description,
|
|
166
|
+
parameters: {
|
|
167
|
+
type: 'object',
|
|
168
|
+
properties: mcpTool.inputSchema.properties,
|
|
169
|
+
required: mcpTool.inputSchema.required,
|
|
170
|
+
},
|
|
171
|
+
}),
|
|
172
|
+
};
|
|
173
|
+
return tool;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Wrap all tools from an MCP client as Cogitator tools
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* const client = await MCPClient.connect({ ... });
|
|
181
|
+
* const tools = await wrapMCPTools(client);
|
|
182
|
+
*
|
|
183
|
+
* const agent = new Agent({
|
|
184
|
+
* tools: [...tools, ...otherTools],
|
|
185
|
+
* });
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export async function wrapMCPTools(client, options) {
|
|
189
|
+
const definitions = await client.listToolDefinitions();
|
|
190
|
+
return definitions.map((def) => mcpToCogitator(def, client, options));
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Convert a tool execution result to MCP content format
|
|
194
|
+
*/
|
|
195
|
+
export function resultToMCPContent(result) {
|
|
196
|
+
if (result === null || result === undefined) {
|
|
197
|
+
return [{ type: 'text', text: '' }];
|
|
198
|
+
}
|
|
199
|
+
if (typeof result === 'string') {
|
|
200
|
+
return [{ type: 'text', text: result }];
|
|
201
|
+
}
|
|
202
|
+
if (typeof result === 'object') {
|
|
203
|
+
if (Array.isArray(result) &&
|
|
204
|
+
result.every((item) => typeof item === 'object' && 'type' in item)) {
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
return [{ type: 'text', text: JSON.stringify(result, null, 2) }];
|
|
208
|
+
}
|
|
209
|
+
return [{ type: 'text', text: String(result) }];
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Convert MCP content to a simple result value
|
|
213
|
+
*/
|
|
214
|
+
export function mcpContentToResult(content) {
|
|
215
|
+
if (!content || content.length === 0) {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
if (content.length === 1 && content[0].type === 'text') {
|
|
219
|
+
const text = content[0].text;
|
|
220
|
+
try {
|
|
221
|
+
return JSON.parse(text);
|
|
222
|
+
}
|
|
223
|
+
catch {
|
|
224
|
+
return text;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
return content.map((item) => {
|
|
228
|
+
if (item.type === 'text') {
|
|
229
|
+
try {
|
|
230
|
+
return JSON.parse(item.text);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
return item.text;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return item;
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=tool-adapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-adapter.js","sourceRoot":"","sources":["../../src/adapter/tool-adapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,CAAC,EAAqD,MAAM,KAAK,CAAC;AAC3E,OAAO,EAAE,eAAe,IAAI,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAK3E;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAkB;IAKhD,MAAM,UAAU,GAAG,kBAAkB,CAAC,MAAM,EAAE;QAC5C,YAAY,EAAE,MAAM;QACpB,MAAM,EAAE,UAAU;KACnB,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,UAAqC,CAAC;IACrD,OAAO,MAAM,CAAC,OAAO,CAAC;IAEtB,OAAO,MAIN,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAI/B;IACC,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;QACnD,OAAO,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACtB,CAAC;IAED,MAAM,KAAK,GAAgB,EAAE,CAAC;IAC9B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC;IAEhD,KAAK,MAAM,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CA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Connects to external MCP servers and provides access to their tools,
|
|
5
|
+
* resources, and prompts.
|
|
6
|
+
*/
|
|
7
|
+
import type { Tool } from '@cogitator-ai/types';
|
|
8
|
+
import type { MCPClientConfig, MCPResource, MCPResourceContent, MCPPrompt, MCPPromptMessage, MCPToolDefinition } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* MCP Client for connecting to external MCP servers
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* // Connect to a filesystem MCP server
|
|
15
|
+
* const client = await MCPClient.connect({
|
|
16
|
+
* transport: 'stdio',
|
|
17
|
+
* command: 'npx',
|
|
18
|
+
* args: ['-y', '@anthropic/mcp-server-filesystem', '/allowed/path'],
|
|
19
|
+
* });
|
|
20
|
+
*
|
|
21
|
+
* // Get available tools as Cogitator tools
|
|
22
|
+
* const tools = await client.getTools();
|
|
23
|
+
*
|
|
24
|
+
* // Use them with an agent
|
|
25
|
+
* const agent = new Agent({
|
|
26
|
+
* tools: [...tools],
|
|
27
|
+
* ...
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* // Don't forget to disconnect
|
|
31
|
+
* await client.close();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare class MCPClient {
|
|
35
|
+
private client;
|
|
36
|
+
private transport;
|
|
37
|
+
private connected;
|
|
38
|
+
private serverCapabilities;
|
|
39
|
+
private constructor();
|
|
40
|
+
/**
|
|
41
|
+
* Connect to an MCP server
|
|
42
|
+
*/
|
|
43
|
+
static connect(config: MCPClientConfig): Promise<MCPClient>;
|
|
44
|
+
/**
|
|
45
|
+
* Create transport based on configuration
|
|
46
|
+
*/
|
|
47
|
+
private static createTransport;
|
|
48
|
+
/**
|
|
49
|
+
* Initialize connection and capabilities
|
|
50
|
+
*/
|
|
51
|
+
private initialize;
|
|
52
|
+
/**
|
|
53
|
+
* Check if connected to server
|
|
54
|
+
*/
|
|
55
|
+
isConnected(): boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Get server capabilities
|
|
58
|
+
*/
|
|
59
|
+
getCapabilities(): typeof this.serverCapabilities;
|
|
60
|
+
/**
|
|
61
|
+
* List available tools from the MCP server
|
|
62
|
+
*/
|
|
63
|
+
listToolDefinitions(): Promise<MCPToolDefinition[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Get MCP tools as Cogitator Tool instances
|
|
66
|
+
*
|
|
67
|
+
* These tools can be directly used with Cogitator agents.
|
|
68
|
+
*/
|
|
69
|
+
getTools(): Promise<Tool[]>;
|
|
70
|
+
/**
|
|
71
|
+
* Call a tool on the MCP server
|
|
72
|
+
*/
|
|
73
|
+
callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
74
|
+
/**
|
|
75
|
+
* List available resources from the MCP server
|
|
76
|
+
*/
|
|
77
|
+
listResources(): Promise<MCPResource[]>;
|
|
78
|
+
/**
|
|
79
|
+
* Read a resource from the MCP server
|
|
80
|
+
*/
|
|
81
|
+
readResource(uri: string): Promise<MCPResourceContent>;
|
|
82
|
+
/**
|
|
83
|
+
* List available prompts from the MCP server
|
|
84
|
+
*/
|
|
85
|
+
listPrompts(): Promise<MCPPrompt[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Get a prompt from the MCP server
|
|
88
|
+
*/
|
|
89
|
+
getPrompt(name: string, args?: Record<string, string>): Promise<MCPPromptMessage[]>;
|
|
90
|
+
/**
|
|
91
|
+
* Close the connection to the MCP server
|
|
92
|
+
*/
|
|
93
|
+
close(): Promise<void>;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Helper function to connect to an MCP server and get tools in one step
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const { tools, cleanup } = await connectMCPServer({
|
|
101
|
+
* transport: 'stdio',
|
|
102
|
+
* command: 'npx',
|
|
103
|
+
* args: ['-y', '@anthropic/mcp-server-filesystem', '/path'],
|
|
104
|
+
* });
|
|
105
|
+
*
|
|
106
|
+
* const agent = new Agent({ tools });
|
|
107
|
+
*
|
|
108
|
+
* // When done
|
|
109
|
+
* await cleanup();
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
export declare function connectMCPServer(config: MCPClientConfig): Promise<{
|
|
113
|
+
client: MCPClient;
|
|
114
|
+
tools: Tool[];
|
|
115
|
+
cleanup: () => Promise<void>;
|
|
116
|
+
}>;
|
|
117
|
+
//# sourceMappingURL=mcp-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-client.d.ts","sourceRoot":"","sources":["../../src/client/mcp-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,KAAK,EACV,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,SAAS,EACT,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,UAAU,CAAC;AAGlB;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAY;IAC7B,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,kBAAkB,CAInB;IAEP,OAAO;IAKP;;OAEG;WACU,OAAO,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,SAAS,CAAC;IAajE;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IA0B9B;;OAEG;YACW,UAAU;IAyBxB;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,eAAe,IAAI,OAAO,IAAI,CAAC,kBAAkB;IAIjD;;OAEG;IACG,mBAAmB,IAAI,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAczD;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAKjC;;OAEG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM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