@amitdeshmukh/ax-crew 3.10.0 → 3.11.3

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 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, MCPHTTPTransportConfig } from '../types.js';
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 isHTTPTransport(config: MCPTransportConfig): config is MCPHTTPTransportConfig;
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,8 @@ 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, AxMCPHTTPTransport } from '@ax-llm/ax';
5
+ import { AxMCPClient, AxMCPHTTPSSETransport, AxMCPStreambleHTTPTransport } from '@ax-llm/ax';
6
+ import { AxMCPStdioTransport } from '@ax-llm/ax-tools';
6
7
  import { PROVIDER_API_KEYS } from '../config/index.js';
7
8
  // Define a mapping from provider names to their respective constructors
8
9
  const AIConstructors = {
@@ -24,10 +25,14 @@ const AIConstructors = {
24
25
  export function isStdioTransport(config) {
25
26
  return 'command' in config;
26
27
  }
27
- // Type guard to check if config is http transport
28
- export function isHTTPTransport(config) {
28
+ // Type guard to check if config is HTTP SSE transport (also handles legacy HTTP transport)
29
+ export function isHTTPSSETransport(config) {
29
30
  return 'sseUrl' in config;
30
31
  }
32
+ // Type guard to check if config is streamable HTTP transport
33
+ export function isStreambleHTTPTransport(config) {
34
+ return 'mcpEndpoint' in config;
35
+ }
31
36
  /**
32
37
  * Type guard to check if a value is a constructor function for a type T.
33
38
  *
@@ -97,8 +102,11 @@ const initializeMCPServers = async (agentConfigData) => {
97
102
  env: mcpServerConfig.env
98
103
  });
99
104
  }
100
- else if (isHTTPTransport(mcpServerConfig)) {
101
- transport = new AxMCPHTTPTransport(mcpServerConfig.sseUrl);
105
+ else if (isHTTPSSETransport(mcpServerConfig)) {
106
+ transport = new AxMCPHTTPSSETransport(mcpServerConfig.sseUrl);
107
+ }
108
+ else if (isStreambleHTTPTransport(mcpServerConfig)) {
109
+ transport = new AxMCPStreambleHTTPTransport(mcpServerConfig.mcpEndpoint, mcpServerConfig.options);
102
110
  }
103
111
  else {
104
112
  throw new Error(`Unsupported transport type: ${JSON.stringify(mcpServerConfig)}`);
@@ -10,7 +10,7 @@ declare class StatefulAxAgent extends AxAgent<any, any> {
10
10
  name: string;
11
11
  description: string;
12
12
  signature: string | AxSignature;
13
- agents?: AxAgentic[] | undefined;
13
+ agents?: AxAgentic<any, any>[] | undefined;
14
14
  functions?: (AxFunction | (() => AxFunction))[] | undefined;
15
15
  examples?: Array<Record<string, any>> | undefined;
16
16
  mcpServers?: Record<string, MCPTransportConfig> | undefined;
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, AxProgramForwardOptions } 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
- interface MCPHTTPTransportConfig {
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 | MCPHTTPTransportConfig} config - The config for the MCP server. Config can be either a stdio or http transport.
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 | MCPHTTPTransportConfig;
129
+ type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPSSETransportConfig | MCPStreambleHTTPTransportConfig;
115
130
  /**
116
131
  * The configuration for an agent.
117
132
  *
@@ -123,7 +138,7 @@ type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPTransportConfig;
123
138
  * @property {AxModelConfig & { model: string }} ai - The AI model configuration to be passed to the agent.
124
139
  * @property {boolean} debug - Whether to enable debug mode.
125
140
  * @property {string} apiURL - Set this if you are using a custom API URL e.g. ollama on localhost.
126
- * @property {Record<string, any>} options - Agent options. Refer to the Ax documentation for more details.
141
+ * @property {Partial<AxProgramForwardOptions>} options - Agent options including thinkingTokenBudget, showThoughts, etc. Refer to the Ax documentation for more details.
127
142
  * @property {string[]} functions - Function names to be used by the agent.
128
143
  * @property {string[]} agents - Sub-agent available to the agent.
129
144
  * @property {Record<string, any>[]} examples - DSPy examples for the agent to learn from.
@@ -140,7 +155,7 @@ interface AgentConfig {
140
155
  };
141
156
  debug?: boolean;
142
157
  apiURL?: string;
143
- options?: Record<string, any>;
158
+ options?: Partial<AxProgramForwardOptions>;
144
159
  functions?: string[];
145
160
  agents?: string[];
146
161
  examples?: Array<Record<string, any>>;
@@ -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 MCPHTTPTransportConfig, type MCPTransportConfig, type ModelUsage, type ModelInfo, type UsageCost, type AggregatedCosts };
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 };
@@ -0,0 +1,89 @@
1
+ import { AxCrew } from "../dist/index.js";
2
+
3
+ import dotenv from "dotenv";
4
+ dotenv.config();
5
+
6
+ // Define the crew configuration
7
+ const config = {
8
+ crew: [
9
+ {
10
+ name: "DeepResearchAgent",
11
+ description: "A specialized agent that performs deep research using perplexity",
12
+ signature: 'researchTopic:string "a topic of interest" -> result:string "The result of the research"',
13
+ provider: "openai",
14
+ providerKeyName: "OPENAI_API_KEY",
15
+ ai: {
16
+ model: "gpt-4.1",
17
+ temperature: 0.1,
18
+ },
19
+ options: {
20
+ stream: true,
21
+ debug: true,
22
+ },
23
+ mcpServers: {
24
+ "perplexity-mcp": {
25
+ "env": {
26
+ "PERPLEXITY_API_KEY": process.env.PERPLEXITY_API_KEY,
27
+ "PERPLEXITY_MODEL": "sonar-deep-research"
28
+ },
29
+ "command": "uvx",
30
+ "args": [
31
+ "perplexity-mcp"
32
+ ]
33
+ }
34
+ }
35
+ }
36
+ ]
37
+ };
38
+
39
+ // Create a new instance of AxCrew with the config
40
+ const crew = new AxCrew(config);
41
+
42
+ // Add the agents to the crew
43
+ await crew.addAllAgents();
44
+
45
+ // Get agent instances
46
+ const researchAgent = crew.agents?.get("DeepResearchAgent");
47
+
48
+ const userQuery: string = "You are a Research assistant. Your task is to analyse the company SpaceX, its origins, current team members, customer profile and any news worthy happenings. Prepare a detailed report.";
49
+
50
+ console.log(`\n\nUser Query: ${userQuery}`);
51
+
52
+ const main = async (): Promise<void> => {
53
+ // Start timing
54
+ const startTime = Date.now();
55
+ console.log(`\n🕐 Starting research task at: ${new Date(startTime).toLocaleTimeString()}`);
56
+
57
+ const response = await researchAgent?.streamingForward({
58
+ researchTopic: userQuery,
59
+ });
60
+
61
+ if (response) {
62
+ try {
63
+ for await (const chunk of response) {
64
+ if (chunk.delta && typeof chunk.delta === 'object' && 'results' in chunk.delta) {
65
+ process.stdout.write(chunk.delta.results);
66
+ }
67
+ }
68
+ console.log('\n');
69
+ } catch (error) {
70
+ console.error('Error processing stream:', error);
71
+ }
72
+ }
73
+
74
+ // End timing and calculate duration
75
+ const endTime = Date.now();
76
+ const duration = endTime - startTime;
77
+ const durationInSeconds = (duration / 1000).toFixed(2);
78
+ const durationInMinutes = (duration / 60000).toFixed(2);
79
+
80
+ console.log(`\n⏱️ Task completed at: ${new Date(endTime).toLocaleTimeString()}`);
81
+ console.log(`⏱️ Total time taken: ${duration}ms (${durationInSeconds}s / ${durationInMinutes}min)`);
82
+ };
83
+
84
+ main()
85
+ .then(() => {
86
+ console.log("Done");
87
+ process.exit(0);
88
+ })
89
+ .catch(console.error);
@@ -0,0 +1,74 @@
1
+ import { AxCrew } from "../dist/index.js";
2
+
3
+ import dotenv from "dotenv";
4
+ dotenv.config();
5
+
6
+ // Define the crew configuration
7
+ const config = {
8
+ crew: [
9
+ {
10
+ name: "XSearchAgent",
11
+ description: "A specialized agent that can search X (Twitter) posts for the latest news and updates about specific topics, people, or events. It can find trending posts, recent tweets, and real-time information from X platform.",
12
+ signature: 'searchQuery:string "a search query" -> result:string "the response to the user query citing relevant sources including X posts and other web sources"',
13
+ provider: "grok",
14
+ providerKeyName: "GROK_API_KEY",
15
+ ai: {
16
+ model: "grok-3-latest",
17
+ temperature: 0.1,
18
+ },
19
+ options: {
20
+ stream: true,
21
+ debug: true,
22
+ searchParameters: {
23
+ mode: 'on',
24
+ returnCitations: true,
25
+ maxSearchResults: 10,
26
+ sources: [
27
+ { type: 'x' },
28
+ { type: 'web' },
29
+ { type: 'news' }
30
+ ]
31
+ }
32
+ }
33
+ }
34
+ ]
35
+ };
36
+
37
+ // Create a new instance of AxCrew with the config
38
+ const crew = new AxCrew(config);
39
+
40
+ // Add the agents to the crew
41
+ await crew.addAllAgents();
42
+
43
+ // Get agent instances
44
+ const xSearchAgent = crew.agents?.get("XSearchAgent");
45
+
46
+ const userQuery: string = "when is the next ISRO launch date and what is the launch vehicle and payload";
47
+
48
+ console.log(`\n\nUser Query: ${userQuery}`);
49
+
50
+ const main = async (): Promise<void> => {
51
+ const response = await xSearchAgent?.streamingForward({
52
+ searchQuery: userQuery,
53
+ });
54
+
55
+ if (response) {
56
+ try {
57
+ for await (const chunk of response) {
58
+ if (chunk.delta && typeof chunk.delta === 'object' && 'results' in chunk.delta) {
59
+ process.stdout.write(chunk.delta.results);
60
+ }
61
+ }
62
+ console.log('\n');
63
+ } catch (error) {
64
+ console.error('Error processing stream:', error);
65
+ }
66
+ }
67
+ };
68
+
69
+ main()
70
+ .then(() => {
71
+ console.log("Done");
72
+ process.exit(0);
73
+ })
74
+ .catch(console.error);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@amitdeshmukh/ax-crew",
4
- "version": "3.10.0",
4
+ "version": "3.11.3",
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",
@@ -23,7 +23,8 @@
23
23
  "uuid": "^10.0.0"
24
24
  },
25
25
  "peerDependencies": {
26
- "@ax-llm/ax": "^11.0.47"
26
+ "@ax-llm/ax": "^13.0.8",
27
+ "@ax-llm/ax-tools": "^13.0.8"
27
28
  },
28
29
  "devDependencies": {
29
30
  "@testing-library/jest-dom": "^6.6.3",
@@ -4,7 +4,8 @@ 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, AxMCPHTTPTransport } from '@ax-llm/ax'
7
+ import { AxMCPClient, AxMCPHTTPSSETransport, AxMCPStreambleHTTPTransport } from '@ax-llm/ax'
8
+ import { AxMCPStdioTransport } from '@ax-llm/ax-tools'
8
9
  import { PROVIDER_API_KEYS } from '../config/index.js';
9
10
  import type {
10
11
  AgentConfig,
@@ -12,7 +13,8 @@ import type {
12
13
  FunctionRegistryType,
13
14
  MCPTransportConfig,
14
15
  MCPStdioTransportConfig,
15
- MCPHTTPTransportConfig
16
+ MCPHTTPSSETransportConfig,
17
+ MCPStreambleHTTPTransportConfig
16
18
  } from '../types.js';
17
19
 
18
20
  // Define a mapping from provider names to their respective constructors
@@ -40,11 +42,16 @@ export function isStdioTransport(config: MCPTransportConfig): config is MCPStdio
40
42
  return 'command' in config;
41
43
  }
42
44
 
43
- // Type guard to check if config is http transport
44
- export function isHTTPTransport(config: MCPTransportConfig): config is MCPHTTPTransportConfig {
45
+ // Type guard to check if config is HTTP SSE transport (also handles legacy HTTP transport)
46
+ export function isHTTPSSETransport(config: MCPTransportConfig): config is MCPHTTPSSETransportConfig {
45
47
  return 'sseUrl' in config;
46
48
  }
47
49
 
50
+ // Type guard to check if config is streamable HTTP transport
51
+ export function isStreambleHTTPTransport(config: MCPTransportConfig): config is MCPStreambleHTTPTransportConfig {
52
+ return 'mcpEndpoint' in config;
53
+ }
54
+
48
55
  /**
49
56
  * Type guard to check if a value is a constructor function for a type T.
50
57
  *
@@ -122,8 +129,10 @@ const initializeMCPServers = async (agentConfigData: AgentConfig): Promise<AxFun
122
129
  args: mcpServerConfig.args,
123
130
  env: mcpServerConfig.env
124
131
  });
125
- } else if (isHTTPTransport(mcpServerConfig)) {
126
- transport = new AxMCPHTTPTransport(mcpServerConfig.sseUrl);
132
+ } else if (isHTTPSSETransport(mcpServerConfig)) {
133
+ transport = new AxMCPHTTPSSETransport(mcpServerConfig.sseUrl);
134
+ } else if (isStreambleHTTPTransport(mcpServerConfig)) {
135
+ transport = new AxMCPStreambleHTTPTransport(mcpServerConfig.mcpEndpoint, mcpServerConfig.options);
127
136
  } else {
128
137
  throw new Error(`Unsupported transport type: ${JSON.stringify(mcpServerConfig)}`);
129
138
  }
@@ -50,7 +50,7 @@ class StatefulAxAgent extends AxAgent<any, any> {
50
50
  name: string;
51
51
  description: string;
52
52
  signature: string | AxSignature;
53
- agents?: AxAgentic[] | undefined;
53
+ agents?: AxAgentic<any, any>[] | undefined;
54
54
  functions?: (AxFunction | (() => AxFunction))[] | undefined;
55
55
  examples?: Array<Record<string, any>> | undefined;
56
56
  mcpServers?: Record<string, MCPTransportConfig> | undefined;
package/src/types.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  import type {
2
2
  AxFunction,
3
3
  AxSignature,
4
- AxModelConfig
4
+ AxModelConfig,
5
+ AxMCPStreamableHTTPTransportOptions,
6
+ AxProgramForwardOptions
5
7
  } from '@ax-llm/ax';
6
8
 
7
9
  import type { Provider } from './agents/agentConfig.js';
@@ -115,15 +117,32 @@ interface MCPStdioTransportConfig {
115
117
  env?: NodeJS.ProcessEnv
116
118
  }
117
119
 
118
- interface MCPHTTPTransportConfig {
120
+ /**
121
+ * Config for an HTTP SSE MCP server.
122
+ *
123
+ * @property {string} sseUrl - The SSE URL for the MCP server.
124
+ */
125
+ interface MCPHTTPSSETransportConfig {
119
126
  sseUrl: string
120
127
  }
128
+
129
+ /**
130
+ * Config for a streamable HTTP MCP server.
131
+ *
132
+ * @property {string} mcpEndpoint - The HTTP endpoint URL for the MCP server.
133
+ * @property {AxMCPStreamableHTTPTransportOptions} options - Optional transport options.
134
+ */
135
+ interface MCPStreambleHTTPTransportConfig {
136
+ mcpEndpoint: string
137
+ options?: AxMCPStreamableHTTPTransportOptions
138
+ }
139
+
121
140
  /**
122
141
  * Config for an MCP server.
123
142
  *
124
- * @property {MCPStdioTransportConfig | MCPHTTPTransportConfig} config - The config for the MCP server. Config can be either a stdio or http transport.
143
+ * @property {MCPStdioTransportConfig | MCPHTTPSSETransportConfig | MCPStreambleHTTPTransportConfig} config - The config for the MCP server. Config can be either stdio, http-sse, or streamable http transport.
125
144
  */
126
- type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPTransportConfig
145
+ type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPSSETransportConfig | MCPStreambleHTTPTransportConfig
127
146
 
128
147
  /**
129
148
  * The configuration for an agent.
@@ -136,7 +155,7 @@ type MCPTransportConfig = MCPStdioTransportConfig | MCPHTTPTransportConfig
136
155
  * @property {AxModelConfig & { model: string }} ai - The AI model configuration to be passed to the agent.
137
156
  * @property {boolean} debug - Whether to enable debug mode.
138
157
  * @property {string} apiURL - Set this if you are using a custom API URL e.g. ollama on localhost.
139
- * @property {Record<string, any>} options - Agent options. Refer to the Ax documentation for more details.
158
+ * @property {Partial<AxProgramForwardOptions>} options - Agent options including thinkingTokenBudget, showThoughts, etc. Refer to the Ax documentation for more details.
140
159
  * @property {string[]} functions - Function names to be used by the agent.
141
160
  * @property {string[]} agents - Sub-agent available to the agent.
142
161
  * @property {Record<string, any>[]} examples - DSPy examples for the agent to learn from.
@@ -151,7 +170,7 @@ interface AgentConfig {
151
170
  ai: AxModelConfig & { model: string };
152
171
  debug?: boolean;
153
172
  apiURL?: string;
154
- options?: Record<string, any>;
173
+ options?: Partial<AxProgramForwardOptions>;
155
174
  functions?: string[];
156
175
  agents?: string[];
157
176
  examples?: Array<Record<string, any>>;
@@ -170,7 +189,8 @@ export {
170
189
  type StateInstance,
171
190
  type FunctionRegistryType,
172
191
  type MCPStdioTransportConfig,
173
- type MCPHTTPTransportConfig,
192
+ type MCPHTTPSSETransportConfig,
193
+ type MCPStreambleHTTPTransportConfig,
174
194
  type MCPTransportConfig,
175
195
  type ModelUsage,
176
196
  type ModelInfo,