@amitdeshmukh/ax-crew 3.10.0 → 3.11.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/CHANGELOG.md +23 -0
- package/README.md +241 -0
- package/agentConfig.json +27 -0
- package/dist/agents/agentConfig.d.ts +3 -2
- package/dist/agents/agentConfig.js +13 -5
- package/dist/types.d.ts +20 -5
- package/package.json +2 -4
- package/src/agents/agentConfig.ts +15 -6
- package/src/types.ts +24 -5
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,29 @@ This Changelog format is based on [Keep a Changelog]
|
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/
|
|
6
6
|
v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [3.11.1] - 2025-06-04
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- Updated MCP (Model Context Protocol) transport implementation to support current ax-llm/ax framework
|
|
12
|
+
- Replaced deprecated `AxMCPHTTPTransport` with `AxMCPHTTPSSETransport` for HTTP SSE transport
|
|
13
|
+
- Added support for `AxMCPStreambleHTTPTransport` for streamable HTTP communication
|
|
14
|
+
- Enhanced MCP configuration with proper TypeScript types using `AxMCPStreamableHTTPTransportOptions`
|
|
15
|
+
- Updated transport configuration to use `mcpEndpoint` parameter for streamable HTTP transport
|
|
16
|
+
|
|
17
|
+
### Removed
|
|
18
|
+
- Removed all references to deprecated `MCPHTTPTransportConfig` interface
|
|
19
|
+
- Cleaned up deprecated MCP transport type definitions
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- Comprehensive MCP documentation in README.md with examples for all transport types
|
|
23
|
+
- Added examples for STDIO, HTTP SSE, and streamable HTTP transport configurations
|
|
24
|
+
- Enhanced MCP server configuration examples including filesystem, search, and database servers
|
|
25
|
+
- Added migration guide for users upgrading from deprecated transport types
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
- Improved type safety for MCP transport configurations
|
|
29
|
+
- Enhanced error handling for unsupported MCP transport types
|
|
30
|
+
|
|
8
31
|
## [3.10.0] - 2025-05-28
|
|
9
32
|
|
|
10
33
|
### Added
|
package/README.md
CHANGED
|
@@ -424,6 +424,247 @@ Key streaming features:
|
|
|
424
424
|
- Compatible with all agent types and configurations
|
|
425
425
|
- Maintains cost tracking and state management functionality
|
|
426
426
|
|
|
427
|
+
### Model Context Protocol (MCP) Support
|
|
428
|
+
|
|
429
|
+
AxCrew provides built-in support for the Model Context Protocol (MCP), allowing agents to connect to and use MCP servers for enhanced functionality. MCP enables agents to access external tools, data sources, and services in a standardized way.
|
|
430
|
+
|
|
431
|
+
#### Supported Transport Types
|
|
432
|
+
|
|
433
|
+
AxCrew supports three MCP transport types, replacing the deprecated `AxMCPHTTPTransport`:
|
|
434
|
+
|
|
435
|
+
1. **AxMCPStdioTransport** - For standard input/output communication
|
|
436
|
+
2. **AxMCPHTTPSSETransport** - For HTTP with Server-Sent Events
|
|
437
|
+
3. **AxMCPStreambleHTTPTransport** - For streamable HTTP communication
|
|
438
|
+
|
|
439
|
+
#### Configuration
|
|
440
|
+
|
|
441
|
+
Add MCP servers to your agent configuration using the `mcpServers` field:
|
|
442
|
+
|
|
443
|
+
##### STDIO Transport Configuration
|
|
444
|
+
|
|
445
|
+
For MCP servers that communicate via standard input/output:
|
|
446
|
+
|
|
447
|
+
```json
|
|
448
|
+
{
|
|
449
|
+
"name": "DataAnalyst",
|
|
450
|
+
"description": "Analyzes data using MCP tools",
|
|
451
|
+
"signature": "data:string -> analysis:string",
|
|
452
|
+
"provider": "openai",
|
|
453
|
+
"providerKeyName": "OPENAI_API_KEY",
|
|
454
|
+
"ai": {
|
|
455
|
+
"model": "gpt-4",
|
|
456
|
+
"temperature": 0
|
|
457
|
+
},
|
|
458
|
+
"mcpServers": {
|
|
459
|
+
"filesystem": {
|
|
460
|
+
"command": "npx",
|
|
461
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"],
|
|
462
|
+
"env": {
|
|
463
|
+
"NODE_ENV": "production"
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
"brave-search": {
|
|
467
|
+
"command": "npx",
|
|
468
|
+
"args": ["-y", "@modelcontextprotocol/server-brave-search"]
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
```
|
|
473
|
+
|
|
474
|
+
##### HTTP SSE Transport Configuration
|
|
475
|
+
|
|
476
|
+
For MCP servers accessible via HTTP with Server-Sent Events:
|
|
477
|
+
|
|
478
|
+
```json
|
|
479
|
+
{
|
|
480
|
+
"name": "WebAnalyst",
|
|
481
|
+
"description": "Analyzes web content using MCP tools",
|
|
482
|
+
"signature": "url:string -> analysis:string",
|
|
483
|
+
"provider": "anthropic",
|
|
484
|
+
"providerKeyName": "ANTHROPIC_API_KEY",
|
|
485
|
+
"ai": {
|
|
486
|
+
"model": "claude-3-haiku",
|
|
487
|
+
"temperature": 0
|
|
488
|
+
},
|
|
489
|
+
"mcpServers": {
|
|
490
|
+
"api-server": {
|
|
491
|
+
"sseUrl": "https://api.example.com/mcp/sse"
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
}
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
##### Streamable HTTP Transport Configuration
|
|
498
|
+
|
|
499
|
+
For MCP servers that support streamable HTTP communication:
|
|
500
|
+
|
|
501
|
+
```json
|
|
502
|
+
{
|
|
503
|
+
"name": "StreamAnalyst",
|
|
504
|
+
"description": "Processes streaming data using MCP tools",
|
|
505
|
+
"signature": "stream:string -> results:string",
|
|
506
|
+
"provider": "google-gemini",
|
|
507
|
+
"providerKeyName": "GEMINI_API_KEY",
|
|
508
|
+
"ai": {
|
|
509
|
+
"model": "gemini-1.5-pro",
|
|
510
|
+
"temperature": 0
|
|
511
|
+
},
|
|
512
|
+
"mcpServers": {
|
|
513
|
+
"stream-processor": {
|
|
514
|
+
"mcpEndpoint": "http://localhost:3002/stream",
|
|
515
|
+
"options": {
|
|
516
|
+
"authorization": "Bearer ey.JhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..-1234567890.1234567890",
|
|
517
|
+
"headers": { // Custom headers to include with all HTTP requests Note: Content-Type, Accept, and Mcp-Session-Id are managed automatically
|
|
518
|
+
"X-Custom-Header": "custom-value"
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
##### Mixed Transport Configuration
|
|
527
|
+
|
|
528
|
+
You can use multiple transport types within the same agent:
|
|
529
|
+
|
|
530
|
+
```json
|
|
531
|
+
{
|
|
532
|
+
"name": "MultiModalAgent",
|
|
533
|
+
"description": "Uses multiple MCP servers with different transports",
|
|
534
|
+
"signature": "task:string -> result:string",
|
|
535
|
+
"provider": "openai",
|
|
536
|
+
"providerKeyName": "OPENAI_API_KEY",
|
|
537
|
+
"ai": {
|
|
538
|
+
"model": "gpt-4",
|
|
539
|
+
"temperature": 0
|
|
540
|
+
},
|
|
541
|
+
"mcpServers": {
|
|
542
|
+
"local-files": {
|
|
543
|
+
"command": "npx",
|
|
544
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/workspace"]
|
|
545
|
+
},
|
|
546
|
+
"web-search": {
|
|
547
|
+
"sseUrl": "http://localhost:3001/sse"
|
|
548
|
+
},
|
|
549
|
+
"data-stream": {
|
|
550
|
+
"mcpEndpoint": "http://localhost:3002/stream"
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
```
|
|
555
|
+
|
|
556
|
+
#### MCP Server Examples
|
|
557
|
+
|
|
558
|
+
Here are some popular MCP servers you can use:
|
|
559
|
+
|
|
560
|
+
**Filesystem Server** (STDIO):
|
|
561
|
+
```json
|
|
562
|
+
"filesystem": {
|
|
563
|
+
"command": "npx",
|
|
564
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/allowed/path"]
|
|
565
|
+
}
|
|
566
|
+
```
|
|
567
|
+
|
|
568
|
+
**Brave Search Server** (STDIO):
|
|
569
|
+
```json
|
|
570
|
+
"brave-search": {
|
|
571
|
+
"command": "npx",
|
|
572
|
+
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
|
|
573
|
+
"env": {
|
|
574
|
+
"BRAVE_API_KEY": "your-brave-api-key"
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
**GitHub Server** (STDIO):
|
|
580
|
+
```json
|
|
581
|
+
"github": {
|
|
582
|
+
"command": "npx",
|
|
583
|
+
"args": ["-y", "@modelcontextprotocol/server-github"],
|
|
584
|
+
"env": {
|
|
585
|
+
"GITHUB_PERSONAL_ACCESS_TOKEN": "your-github-token"
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
**PostgreSQL Server** (STDIO):
|
|
591
|
+
```json
|
|
592
|
+
"postgres": {
|
|
593
|
+
"command": "npx",
|
|
594
|
+
"args": ["-y", "@modelcontextprotocol/server-postgres"],
|
|
595
|
+
"env": {
|
|
596
|
+
"POSTGRES_CONNECTION_STRING": "postgresql://user:pass@localhost/db"
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
```
|
|
600
|
+
|
|
601
|
+
#### Usage in Code
|
|
602
|
+
|
|
603
|
+
MCP functions are automatically available to agents once the servers are configured:
|
|
604
|
+
|
|
605
|
+
```javascript
|
|
606
|
+
import { AxCrew } from '@amitdeshmukh/ax-crew';
|
|
607
|
+
|
|
608
|
+
// Create crew with MCP-enabled agents
|
|
609
|
+
const crew = new AxCrew('./agentConfig.json');
|
|
610
|
+
await crew.addAgent('DataAnalyst'); // Agent with MCP servers configured
|
|
611
|
+
|
|
612
|
+
const analyst = crew.agents.get('DataAnalyst');
|
|
613
|
+
|
|
614
|
+
// The agent can now use MCP functions automatically
|
|
615
|
+
const response = await analyst.forward({
|
|
616
|
+
data: "Please analyze the sales data in /workspace/sales.csv"
|
|
617
|
+
});
|
|
618
|
+
// The agent will automatically use the filesystem MCP server to read the file
|
|
619
|
+
// and any other configured MCP tools for analysis
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
#### Best Practices
|
|
623
|
+
|
|
624
|
+
1. **Environment Variables**: Store sensitive information like API keys in environment variables rather than in the configuration file.
|
|
625
|
+
|
|
626
|
+
2. **Path Security**: For filesystem servers, always specify allowed paths to prevent unauthorized file access.
|
|
627
|
+
|
|
628
|
+
3. **Server Health**: Implement health checks for HTTP-based MCP servers to ensure reliability.
|
|
629
|
+
|
|
630
|
+
4. **Error Handling**: MCP server failures are handled gracefully - agents will continue to work with available tools.
|
|
631
|
+
|
|
632
|
+
5. **Debugging**: Enable debug mode to see MCP server initialization and communication logs:
|
|
633
|
+
```json
|
|
634
|
+
{
|
|
635
|
+
"debug": true,
|
|
636
|
+
"mcpServers": { ... }
|
|
637
|
+
}
|
|
638
|
+
```
|
|
639
|
+
|
|
640
|
+
#### Migration from Deprecated Transport
|
|
641
|
+
|
|
642
|
+
If you're upgrading from the deprecated `AxMCPHTTPTransport`, update your configuration:
|
|
643
|
+
|
|
644
|
+
**Before (deprecated):**
|
|
645
|
+
```json
|
|
646
|
+
"mcpServers": {
|
|
647
|
+
"my-server": {
|
|
648
|
+
"sseUrl": "http://localhost:3001/sse"
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
**After (current):**
|
|
654
|
+
The configuration remains the same - the transport type is automatically detected and `AxMCPHTTPSSETransport` is used for `sseUrl` configurations. No changes to your configuration files are needed.
|
|
655
|
+
|
|
656
|
+
For new streamable HTTP servers, use:
|
|
657
|
+
```json
|
|
658
|
+
"mcpServers": {
|
|
659
|
+
"my-stream-server": {
|
|
660
|
+
"mcpEndpoint": "http://localhost:3002/stream",
|
|
661
|
+
"options": {
|
|
662
|
+
"timeout": 30000
|
|
663
|
+
}
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
```
|
|
667
|
+
|
|
427
668
|
### Tracking Usage Costs
|
|
428
669
|
|
|
429
670
|
The package provides precise cost tracking capabilities for monitoring API usage across individual agents and the entire crew. Costs are calculated using high-precision decimal arithmetic to ensure accuracy.
|
package/agentConfig.json
CHANGED
|
@@ -108,6 +108,33 @@
|
|
|
108
108
|
"solution": "Let's solve this step by step:\n1. The cube root of a number is a value that, when multiplied by itself twice, gives the original number\n2. For 27, we need to find a number that when cubed equals 27\n3. 3 × 3 × 3 = 27\nTherefore, the cube root of 27 is 3"
|
|
109
109
|
}
|
|
110
110
|
]
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "DataAnalyst",
|
|
114
|
+
"description": "Analyzes data using MCP tools for file access and web search",
|
|
115
|
+
"signature": "analysisRequest:string \"a request to analyze data from files or web sources\" -> analysis:string \"detailed analysis with insights\"",
|
|
116
|
+
"provider": "openai",
|
|
117
|
+
"providerKeyName": "OPENAI_API_KEY",
|
|
118
|
+
"ai": {
|
|
119
|
+
"model": "gpt-4o-mini",
|
|
120
|
+
"temperature": 0
|
|
121
|
+
},
|
|
122
|
+
"options": {
|
|
123
|
+
"debug": true
|
|
124
|
+
},
|
|
125
|
+
"mcpServers": {
|
|
126
|
+
"filesystem": {
|
|
127
|
+
"command": "npx",
|
|
128
|
+
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
129
|
+
},
|
|
130
|
+
"brave-search": {
|
|
131
|
+
"command": "npx",
|
|
132
|
+
"args": ["-y", "@modelcontextprotocol/server-brave-search"],
|
|
133
|
+
"env": {
|
|
134
|
+
"BRAVE_API_KEY": "sk-1234567890"
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
111
138
|
}
|
|
112
139
|
]
|
|
113
140
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { AxFunction } from '@ax-llm/ax';
|
|
2
|
-
import type { AgentConfig, CrewConfigInput, FunctionRegistryType, MCPTransportConfig, MCPStdioTransportConfig,
|
|
2
|
+
import type { AgentConfig, CrewConfigInput, FunctionRegistryType, MCPTransportConfig, MCPStdioTransportConfig, MCPHTTPSSETransportConfig, MCPStreambleHTTPTransportConfig } from '../types.js';
|
|
3
3
|
declare const AIConstructors: Record<string, any>;
|
|
4
4
|
export type Provider = keyof typeof AIConstructors;
|
|
5
5
|
export declare function isStdioTransport(config: MCPTransportConfig): config is MCPStdioTransportConfig;
|
|
6
|
-
export declare function
|
|
6
|
+
export declare function isHTTPSSETransport(config: MCPTransportConfig): config is MCPHTTPSSETransportConfig;
|
|
7
|
+
export declare function isStreambleHTTPTransport(config: MCPTransportConfig): config is MCPStreambleHTTPTransportConfig;
|
|
7
8
|
/**
|
|
8
9
|
* Parses and returns the AxCrew config from either a JSON config file or a direct JSON object.
|
|
9
10
|
* @param {CrewConfigInput} input - Either a path to the agent config json file or a JSON object with crew configuration.
|
|
@@ -2,7 +2,7 @@ import fs from 'fs';
|
|
|
2
2
|
// Import all the providers
|
|
3
3
|
import { AxAIAnthropic, AxAIOpenAI, AxAIAzureOpenAI, AxAICohere, AxAIDeepSeek, AxAIGoogleGemini, AxAIGroq, AxAIHuggingFace, AxAIMistral, AxAIOllama, AxAITogether, AxAIReka, AxAIGrok } from '@ax-llm/ax';
|
|
4
4
|
// Import the MCP client and transports
|
|
5
|
-
import { AxMCPClient, AxMCPStdioTransport,
|
|
5
|
+
import { AxMCPClient, AxMCPStdioTransport, AxMCPHTTPSSETransport, AxMCPStreambleHTTPTransport } from '@ax-llm/ax';
|
|
6
6
|
import { PROVIDER_API_KEYS } from '../config/index.js';
|
|
7
7
|
// Define a mapping from provider names to their respective constructors
|
|
8
8
|
const AIConstructors = {
|
|
@@ -24,10 +24,14 @@ const AIConstructors = {
|
|
|
24
24
|
export function isStdioTransport(config) {
|
|
25
25
|
return 'command' in config;
|
|
26
26
|
}
|
|
27
|
-
// Type guard to check if config is
|
|
28
|
-
export function
|
|
27
|
+
// Type guard to check if config is HTTP SSE transport (also handles legacy HTTP transport)
|
|
28
|
+
export function isHTTPSSETransport(config) {
|
|
29
29
|
return 'sseUrl' in config;
|
|
30
30
|
}
|
|
31
|
+
// Type guard to check if config is streamable HTTP transport
|
|
32
|
+
export function isStreambleHTTPTransport(config) {
|
|
33
|
+
return 'mcpEndpoint' in config;
|
|
34
|
+
}
|
|
31
35
|
/**
|
|
32
36
|
* Type guard to check if a value is a constructor function for a type T.
|
|
33
37
|
*
|
|
@@ -97,8 +101,12 @@ const initializeMCPServers = async (agentConfigData) => {
|
|
|
97
101
|
env: mcpServerConfig.env
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
|
-
else if (
|
|
101
|
-
transport = new
|
|
104
|
+
else if (isStreambleHTTPTransport(mcpServerConfig)) {
|
|
105
|
+
transport = new AxMCPStreambleHTTPTransport(mcpServerConfig.mcpEndpoint, mcpServerConfig.options);
|
|
106
|
+
}
|
|
107
|
+
else if (isHTTPSSETransport(mcpServerConfig)) {
|
|
108
|
+
// This handles both new SSE transport and legacy HTTP transport (both use sseUrl)
|
|
109
|
+
transport = new AxMCPHTTPSSETransport(mcpServerConfig.sseUrl);
|
|
102
110
|
}
|
|
103
111
|
else {
|
|
104
112
|
throw new Error(`Unsupported transport type: ${JSON.stringify(mcpServerConfig)}`);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AxFunction, AxSignature, AxModelConfig } from '@ax-llm/ax';
|
|
1
|
+
import type { AxFunction, AxSignature, AxModelConfig, AxMCPStreamableHTTPTransportOptions } from '@ax-llm/ax';
|
|
2
2
|
import type { Provider } from './agents/agentConfig.js';
|
|
3
3
|
/**
|
|
4
4
|
* A state instance that is shared between agents.
|
|
@@ -103,15 +103,30 @@ interface MCPStdioTransportConfig {
|
|
|
103
103
|
args?: string[];
|
|
104
104
|
env?: NodeJS.ProcessEnv;
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
/**
|
|
107
|
+
* Config for an HTTP SSE MCP server.
|
|
108
|
+
*
|
|
109
|
+
* @property {string} sseUrl - The SSE URL for the MCP server.
|
|
110
|
+
*/
|
|
111
|
+
interface MCPHTTPSSETransportConfig {
|
|
107
112
|
sseUrl: string;
|
|
108
113
|
}
|
|
114
|
+
/**
|
|
115
|
+
* Config for a streamable HTTP MCP server.
|
|
116
|
+
*
|
|
117
|
+
* @property {string} mcpEndpoint - The HTTP endpoint URL for the MCP server.
|
|
118
|
+
* @property {AxMCPStreamableHTTPTransportOptions} options - Optional transport options.
|
|
119
|
+
*/
|
|
120
|
+
interface MCPStreambleHTTPTransportConfig {
|
|
121
|
+
mcpEndpoint: string;
|
|
122
|
+
options?: AxMCPStreamableHTTPTransportOptions;
|
|
123
|
+
}
|
|
109
124
|
/**
|
|
110
125
|
* Config for an MCP server.
|
|
111
126
|
*
|
|
112
|
-
* @property {MCPStdioTransportConfig |
|
|
127
|
+
* @property {MCPStdioTransportConfig | MCPHTTPSSETransportConfig | MCPStreambleHTTPTransportConfig} config - The config for the MCP server. Config can be either stdio, http-sse, or streamable http transport.
|
|
113
128
|
*/
|
|
114
|
-
type MCPTransportConfig = MCPStdioTransportConfig |
|
|
129
|
+
type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPSSETransportConfig | MCPStreambleHTTPTransportConfig;
|
|
115
130
|
/**
|
|
116
131
|
* The configuration for an agent.
|
|
117
132
|
*
|
|
@@ -152,4 +167,4 @@ interface AgentConfig {
|
|
|
152
167
|
type CrewConfigInput = string | {
|
|
153
168
|
crew: AgentConfig[];
|
|
154
169
|
};
|
|
155
|
-
export { type AgentConfig, type CrewConfigInput, type AggregatedMetrics, type StateInstance, type FunctionRegistryType, type MCPStdioTransportConfig, type
|
|
170
|
+
export { type AgentConfig, type CrewConfigInput, type AggregatedMetrics, type StateInstance, type FunctionRegistryType, type MCPStdioTransportConfig, type MCPHTTPSSETransportConfig, type MCPStreambleHTTPTransportConfig, type MCPTransportConfig, type ModelUsage, type ModelInfo, type UsageCost, type AggregatedCosts };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@amitdeshmukh/ax-crew",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.11.1",
|
|
5
5
|
"description": "Build and launch a crew of AI agents with shared state. Built with axllm.dev",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -17,14 +17,12 @@
|
|
|
17
17
|
"test:ui": "vitest --ui"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"@ax-llm/ax": "^11.0.50",
|
|
20
21
|
"decimal.js": "^10.5.0",
|
|
21
22
|
"dotenv": "^16.4.5",
|
|
22
23
|
"upgrade": "^1.1.0",
|
|
23
24
|
"uuid": "^10.0.0"
|
|
24
25
|
},
|
|
25
|
-
"peerDependencies": {
|
|
26
|
-
"@ax-llm/ax": "^11.0.47"
|
|
27
|
-
},
|
|
28
26
|
"devDependencies": {
|
|
29
27
|
"@testing-library/jest-dom": "^6.6.3",
|
|
30
28
|
"@types/node": "^20.14.9",
|
|
@@ -4,7 +4,7 @@ import { AxAIAnthropic, AxAIOpenAI, AxAIAzureOpenAI, AxAICohere, AxAIDeepSeek, A
|
|
|
4
4
|
// Import Ax types
|
|
5
5
|
import type { AxFunction } from '@ax-llm/ax';
|
|
6
6
|
// Import the MCP client and transports
|
|
7
|
-
import { AxMCPClient, AxMCPStdioTransport,
|
|
7
|
+
import { AxMCPClient, AxMCPStdioTransport, AxMCPHTTPSSETransport, AxMCPStreambleHTTPTransport } from '@ax-llm/ax'
|
|
8
8
|
import { PROVIDER_API_KEYS } from '../config/index.js';
|
|
9
9
|
import type {
|
|
10
10
|
AgentConfig,
|
|
@@ -12,7 +12,8 @@ import type {
|
|
|
12
12
|
FunctionRegistryType,
|
|
13
13
|
MCPTransportConfig,
|
|
14
14
|
MCPStdioTransportConfig,
|
|
15
|
-
|
|
15
|
+
MCPHTTPSSETransportConfig,
|
|
16
|
+
MCPStreambleHTTPTransportConfig
|
|
16
17
|
} from '../types.js';
|
|
17
18
|
|
|
18
19
|
// Define a mapping from provider names to their respective constructors
|
|
@@ -40,11 +41,16 @@ export function isStdioTransport(config: MCPTransportConfig): config is MCPStdio
|
|
|
40
41
|
return 'command' in config;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
|
-
// Type guard to check if config is
|
|
44
|
-
export function
|
|
44
|
+
// Type guard to check if config is HTTP SSE transport (also handles legacy HTTP transport)
|
|
45
|
+
export function isHTTPSSETransport(config: MCPTransportConfig): config is MCPHTTPSSETransportConfig {
|
|
45
46
|
return 'sseUrl' in config;
|
|
46
47
|
}
|
|
47
48
|
|
|
49
|
+
// Type guard to check if config is streamable HTTP transport
|
|
50
|
+
export function isStreambleHTTPTransport(config: MCPTransportConfig): config is MCPStreambleHTTPTransportConfig {
|
|
51
|
+
return 'mcpEndpoint' in config;
|
|
52
|
+
}
|
|
53
|
+
|
|
48
54
|
/**
|
|
49
55
|
* Type guard to check if a value is a constructor function for a type T.
|
|
50
56
|
*
|
|
@@ -122,8 +128,11 @@ const initializeMCPServers = async (agentConfigData: AgentConfig): Promise<AxFun
|
|
|
122
128
|
args: mcpServerConfig.args,
|
|
123
129
|
env: mcpServerConfig.env
|
|
124
130
|
});
|
|
125
|
-
} else if (
|
|
126
|
-
transport = new
|
|
131
|
+
} else if (isStreambleHTTPTransport(mcpServerConfig)) {
|
|
132
|
+
transport = new AxMCPStreambleHTTPTransport(mcpServerConfig.mcpEndpoint, mcpServerConfig.options);
|
|
133
|
+
} else if (isHTTPSSETransport(mcpServerConfig)) {
|
|
134
|
+
// This handles both new SSE transport and legacy HTTP transport (both use sseUrl)
|
|
135
|
+
transport = new AxMCPHTTPSSETransport(mcpServerConfig.sseUrl);
|
|
127
136
|
} else {
|
|
128
137
|
throw new Error(`Unsupported transport type: ${JSON.stringify(mcpServerConfig)}`);
|
|
129
138
|
}
|
package/src/types.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AxFunction,
|
|
3
3
|
AxSignature,
|
|
4
|
-
AxModelConfig
|
|
4
|
+
AxModelConfig,
|
|
5
|
+
AxMCPStreamableHTTPTransportOptions
|
|
5
6
|
} from '@ax-llm/ax';
|
|
6
7
|
|
|
7
8
|
import type { Provider } from './agents/agentConfig.js';
|
|
@@ -115,15 +116,32 @@ interface MCPStdioTransportConfig {
|
|
|
115
116
|
env?: NodeJS.ProcessEnv
|
|
116
117
|
}
|
|
117
118
|
|
|
118
|
-
|
|
119
|
+
/**
|
|
120
|
+
* Config for an HTTP SSE MCP server.
|
|
121
|
+
*
|
|
122
|
+
* @property {string} sseUrl - The SSE URL for the MCP server.
|
|
123
|
+
*/
|
|
124
|
+
interface MCPHTTPSSETransportConfig {
|
|
119
125
|
sseUrl: string
|
|
120
126
|
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Config for a streamable HTTP MCP server.
|
|
130
|
+
*
|
|
131
|
+
* @property {string} mcpEndpoint - The HTTP endpoint URL for the MCP server.
|
|
132
|
+
* @property {AxMCPStreamableHTTPTransportOptions} options - Optional transport options.
|
|
133
|
+
*/
|
|
134
|
+
interface MCPStreambleHTTPTransportConfig {
|
|
135
|
+
mcpEndpoint: string
|
|
136
|
+
options?: AxMCPStreamableHTTPTransportOptions
|
|
137
|
+
}
|
|
138
|
+
|
|
121
139
|
/**
|
|
122
140
|
* Config for an MCP server.
|
|
123
141
|
*
|
|
124
|
-
* @property {MCPStdioTransportConfig |
|
|
142
|
+
* @property {MCPStdioTransportConfig | MCPHTTPSSETransportConfig | MCPStreambleHTTPTransportConfig} config - The config for the MCP server. Config can be either stdio, http-sse, or streamable http transport.
|
|
125
143
|
*/
|
|
126
|
-
type MCPTransportConfig = MCPStdioTransportConfig |
|
|
144
|
+
type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPSSETransportConfig | MCPStreambleHTTPTransportConfig
|
|
127
145
|
|
|
128
146
|
/**
|
|
129
147
|
* The configuration for an agent.
|
|
@@ -170,7 +188,8 @@ export {
|
|
|
170
188
|
type StateInstance,
|
|
171
189
|
type FunctionRegistryType,
|
|
172
190
|
type MCPStdioTransportConfig,
|
|
173
|
-
type
|
|
191
|
+
type MCPHTTPSSETransportConfig,
|
|
192
|
+
type MCPStreambleHTTPTransportConfig,
|
|
174
193
|
type MCPTransportConfig,
|
|
175
194
|
type ModelUsage,
|
|
176
195
|
type ModelInfo,
|