rcrewai 0.2.1 → 0.3.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.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +99 -0
- data/CHANGELOG.md +24 -0
- data/README.md +2 -2
- data/Rakefile +53 -53
- data/bin/rcrewai +3 -3
- data/docs/mcp.md +109 -0
- data/docs/superpowers/plans/2026-05-11-llm-modernization.md +2753 -0
- data/docs/superpowers/specs/2026-05-11-llm-modernization-design.md +479 -0
- data/docs/upgrading-to-0.3.md +163 -0
- data/examples/async_execution_example.rb +82 -81
- data/examples/hierarchical_crew_example.rb +68 -72
- data/examples/human_in_the_loop_example.rb +73 -74
- data/examples/mcp_example.rb +48 -0
- data/examples/native_tools_example.rb +64 -0
- data/examples/streaming_example.rb +56 -0
- data/lib/rcrewai/agent.rb +148 -287
- data/lib/rcrewai/async_executor.rb +43 -43
- data/lib/rcrewai/cli.rb +11 -11
- data/lib/rcrewai/configuration.rb +14 -9
- data/lib/rcrewai/crew.rb +56 -39
- data/lib/rcrewai/events.rb +30 -0
- data/lib/rcrewai/human_input.rb +104 -114
- data/lib/rcrewai/legacy_react_runner.rb +172 -0
- data/lib/rcrewai/llm_client.rb +1 -1
- data/lib/rcrewai/llm_clients/anthropic.rb +174 -54
- data/lib/rcrewai/llm_clients/azure.rb +23 -128
- data/lib/rcrewai/llm_clients/base.rb +11 -7
- data/lib/rcrewai/llm_clients/google.rb +159 -95
- data/lib/rcrewai/llm_clients/ollama.rb +150 -106
- data/lib/rcrewai/llm_clients/openai.rb +140 -63
- data/lib/rcrewai/mcp/client.rb +101 -0
- data/lib/rcrewai/mcp/tool_adapter.rb +59 -0
- data/lib/rcrewai/mcp/transport/http.rb +53 -0
- data/lib/rcrewai/mcp/transport/stdio.rb +55 -0
- data/lib/rcrewai/mcp.rb +8 -0
- data/lib/rcrewai/memory.rb +45 -37
- data/lib/rcrewai/pricing.rb +34 -0
- data/lib/rcrewai/process.rb +86 -95
- data/lib/rcrewai/provider_schema.rb +38 -0
- data/lib/rcrewai/sse_parser.rb +55 -0
- data/lib/rcrewai/task.rb +56 -64
- data/lib/rcrewai/tool_runner.rb +132 -0
- data/lib/rcrewai/tool_schema.rb +97 -0
- data/lib/rcrewai/tools/base.rb +98 -37
- data/lib/rcrewai/tools/code_executor.rb +71 -74
- data/lib/rcrewai/tools/email_sender.rb +70 -78
- data/lib/rcrewai/tools/file_reader.rb +38 -30
- data/lib/rcrewai/tools/file_writer.rb +40 -38
- data/lib/rcrewai/tools/pdf_processor.rb +115 -130
- data/lib/rcrewai/tools/sql_database.rb +58 -55
- data/lib/rcrewai/tools/web_search.rb +26 -25
- data/lib/rcrewai/version.rb +2 -2
- data/lib/rcrewai.rb +18 -10
- data/rcrewai.gemspec +39 -39
- metadata +65 -47
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c7682076eeeb0d3c1bdc0de2185c83ad8c925ce19165786daa0910c1925fdf64
|
|
4
|
+
data.tar.gz: 1db4ba5508d8aef52b6645be9cae3dcb7328564f8335a24fe844655196d2f53f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dfaf95b581c86cd36573400729a02e72e307721f51267fefafdb3245aae28bffc89201855dcd294f38ecfc54a6a1dbf2062d92fbd55310e4f2f9d968b49a1a6e
|
|
7
|
+
data.tar.gz: 4c8ed1132d754e92ab154c192f28d8add3d80fdbedbaaa15fa6fd876002f18674d30a91f7ef9fb5dcba65a4240ca9f464d26fa15b64a8cdcdee4ad806cefe3bd
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# This configuration was generated by
|
|
2
|
+
# `rubocop --auto-gen-config`
|
|
3
|
+
# on 2026-05-12 09:06:14 UTC using RuboCop version 1.78.0.
|
|
4
|
+
# The point is for the user to remove these configuration records
|
|
5
|
+
# one by one as the offenses are removed from the code base.
|
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
|
8
|
+
|
|
9
|
+
# Offense count: 2
|
|
10
|
+
Lint/DuplicateMethods:
|
|
11
|
+
Exclude:
|
|
12
|
+
- 'lib/rcrewai/configuration.rb'
|
|
13
|
+
|
|
14
|
+
# Offense count: 55
|
|
15
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
|
16
|
+
Metrics/AbcSize:
|
|
17
|
+
Max: 61
|
|
18
|
+
|
|
19
|
+
# Offense count: 30
|
|
20
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
21
|
+
# AllowedMethods: refine
|
|
22
|
+
Metrics/BlockLength:
|
|
23
|
+
Max: 325
|
|
24
|
+
|
|
25
|
+
# Offense count: 1
|
|
26
|
+
# Configuration parameters: CountBlocks, CountModifierForms.
|
|
27
|
+
Metrics/BlockNesting:
|
|
28
|
+
Max: 4
|
|
29
|
+
|
|
30
|
+
# Offense count: 14
|
|
31
|
+
# Configuration parameters: CountComments, CountAsOne.
|
|
32
|
+
Metrics/ClassLength:
|
|
33
|
+
Max: 408
|
|
34
|
+
|
|
35
|
+
# Offense count: 33
|
|
36
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
37
|
+
Metrics/CyclomaticComplexity:
|
|
38
|
+
Max: 21
|
|
39
|
+
|
|
40
|
+
# Offense count: 99
|
|
41
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
|
42
|
+
Metrics/MethodLength:
|
|
43
|
+
Max: 67
|
|
44
|
+
|
|
45
|
+
# Offense count: 1
|
|
46
|
+
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
|
|
47
|
+
Metrics/ParameterLists:
|
|
48
|
+
Max: 6
|
|
49
|
+
|
|
50
|
+
# Offense count: 18
|
|
51
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns.
|
|
52
|
+
Metrics/PerceivedComplexity:
|
|
53
|
+
Max: 21
|
|
54
|
+
|
|
55
|
+
# Offense count: 1
|
|
56
|
+
# Configuration parameters: NamePrefix, ForbiddenPrefixes, AllowedMethods, MethodDefinitionMacros, UseSorbetSigs.
|
|
57
|
+
# NamePrefix: is_, has_, have_, does_
|
|
58
|
+
# ForbiddenPrefixes: is_, has_, have_, does_
|
|
59
|
+
# AllowedMethods: is_a?
|
|
60
|
+
# MethodDefinitionMacros: define_method, define_singleton_method
|
|
61
|
+
Naming/PredicatePrefix:
|
|
62
|
+
Exclude:
|
|
63
|
+
- 'spec/**/*'
|
|
64
|
+
- 'lib/rcrewai/agent.rb'
|
|
65
|
+
|
|
66
|
+
# Offense count: 32
|
|
67
|
+
# Configuration parameters: AllowedConstants.
|
|
68
|
+
Style/Documentation:
|
|
69
|
+
Enabled: false
|
|
70
|
+
|
|
71
|
+
# Offense count: 23
|
|
72
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
73
|
+
Style/IfUnlessModifier:
|
|
74
|
+
Exclude:
|
|
75
|
+
- 'lib/rcrewai/agent.rb'
|
|
76
|
+
- 'lib/rcrewai/human_input.rb'
|
|
77
|
+
- 'lib/rcrewai/llm_clients/ollama.rb'
|
|
78
|
+
- 'lib/rcrewai/memory.rb'
|
|
79
|
+
- 'lib/rcrewai/process.rb'
|
|
80
|
+
- 'lib/rcrewai/tools/code_executor.rb'
|
|
81
|
+
- 'lib/rcrewai/tools/email_sender.rb'
|
|
82
|
+
- 'lib/rcrewai/tools/file_writer.rb'
|
|
83
|
+
- 'lib/rcrewai/tools/pdf_processor.rb'
|
|
84
|
+
- 'lib/rcrewai/tools/sql_database.rb'
|
|
85
|
+
|
|
86
|
+
# Offense count: 1
|
|
87
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
88
|
+
# Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, IgnoreClassMethods, AllowedMethods.
|
|
89
|
+
# AllowedMethods: to_ary, to_a, to_c, to_enum, to_h, to_hash, to_i, to_int, to_io, to_open, to_path, to_proc, to_r, to_regexp, to_str, to_s, to_sym
|
|
90
|
+
Style/TrivialAccessors:
|
|
91
|
+
Exclude:
|
|
92
|
+
- 'lib/rcrewai/process.rb'
|
|
93
|
+
|
|
94
|
+
# Offense count: 16
|
|
95
|
+
# This cop supports safe autocorrection (--autocorrect).
|
|
96
|
+
# Configuration parameters: AllowHeredoc, AllowURI, AllowQualifiedName, URISchemes, IgnoreCopDirectives, AllowedPatterns, SplitStrings.
|
|
97
|
+
# URISchemes: http, https
|
|
98
|
+
Layout/LineLength:
|
|
99
|
+
Max: 201
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.3.0] - 2026-05-12
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Native function calling across all five providers (OpenAI, Anthropic, Google, Azure, Ollama). Tools declare a JSON schema via the new DSL (`tool_name`, `description`, `param`) on `Tools::Base`.
|
|
14
|
+
- Typed streaming event model (`RCrewAI::Events::*`) covering text deltas, tool-call lifecycle, usage, and errors. Pass `stream:` to `crew.execute` or `agent.execute_task`.
|
|
15
|
+
- MCP (Model Context Protocol) client. Connect to stdio or HTTP MCP servers and expose their tools as ordinary RCrewAI tools (`RCrewAI::MCP::Client.with_connection`).
|
|
16
|
+
- Per-model price table (`RCrewAI::Pricing`) and `cost_usd` on `Events::Usage` for cost tracking.
|
|
17
|
+
- `Tools::Base#execute_with_validation` coerces and validates args against the DSL schema.
|
|
18
|
+
- New `ToolRunner` (native function calling loop) and `LegacyReactRunner` (extracted `USE_TOOL[]` parsing loop).
|
|
19
|
+
- `RCrewAI::SSEParser` — reusable Server-Sent Events parser used by all providers and MCP HTTP transport.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
- `Agent#execute_task` now delegates to `ToolRunner` (native function calling) or `LegacyReactRunner` (existing `USE_TOOL[]` parsing, used as fallback for legacy models or tools without a DSL declaration).
|
|
23
|
+
- `Agent#execute_task` return value is now a hash including `:content`, `:tool_calls_history`, `:usage`, `:iterations`, `:finish_reason`. `task.result` continues to hold the string content.
|
|
24
|
+
- `LLMClients::Base#chat` gains `tools:`, `tool_choice:`, and `stream:` keyword arguments.
|
|
25
|
+
- Provider clients return symbolic `finish_reason` (`:stop`, `:tool_calls`, `:length`) and symbol-keyed `usage`.
|
|
26
|
+
|
|
27
|
+
### Breaking
|
|
28
|
+
- Subclasses of `LLMClients::Base` that override `chat` with an explicit kwarg list must add `tools: nil, stream: nil` to the signature (or accept `**options`).
|
|
29
|
+
- Tools without DSL declarations now receive a permissive fallback schema and emit a one-time deprecation warning to stderr.
|
|
30
|
+
|
|
31
|
+
### Migration
|
|
32
|
+
- See `docs/upgrading-to-0.3.md` for step-by-step migration.
|
|
33
|
+
|
|
10
34
|
## [0.1.0] - 2025-01-12
|
|
11
35
|
|
|
12
36
|
### Added
|
data/README.md
CHANGED
|
@@ -303,7 +303,7 @@ RCrewAI provides a flexible, production-ready architecture:
|
|
|
303
303
|
|
|
304
304
|
### rcrew RAILS
|
|
305
305
|
|
|
306
|
-
For Rails applications, use the **rcrew RAILS** gem (`rcrewai-rails`) which provides:
|
|
306
|
+
For Rails applications, use the **rcrew RAILS** gem (`rcrewai-rails`) [(repo here)](https://github.com/gkosmo/rcrewai-rails) which provides:
|
|
307
307
|
|
|
308
308
|
- **🏗️ Rails Engine**: Mountable engine with web UI for managing crews
|
|
309
309
|
- **💾 ActiveRecord Integration**: Database persistence for agents, tasks, and executions
|
|
@@ -357,4 +357,4 @@ RCrewAI is released under the [MIT License](LICENSE).
|
|
|
357
357
|
|
|
358
358
|
---
|
|
359
359
|
|
|
360
|
-
Made with ❤️ by the RCrewAI community
|
|
360
|
+
Made with ❤️ by the RCrewAI community
|
data/Rakefile
CHANGED
|
@@ -1,130 +1,130 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require 'bundler/gem_tasks'
|
|
4
|
+
require 'rspec/core/rake_task'
|
|
5
|
+
require 'rubocop/rake_task'
|
|
6
6
|
|
|
7
7
|
# Default task
|
|
8
|
-
task default: [
|
|
8
|
+
task default: %i[spec rubocop]
|
|
9
9
|
|
|
10
10
|
# RSpec task
|
|
11
11
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
|
12
|
-
task.rspec_opts =
|
|
12
|
+
task.rspec_opts = '--color --format documentation'
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
# RuboCop task
|
|
16
16
|
RuboCop::RakeTask.new do |task|
|
|
17
|
-
task.options = [
|
|
17
|
+
task.options = ['--display-cop-names', '--display-style-guide']
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
# Test with coverage
|
|
21
|
-
desc
|
|
21
|
+
desc 'Run specs with coverage report'
|
|
22
22
|
task :spec_coverage do
|
|
23
23
|
ENV['COVERAGE'] = 'true'
|
|
24
24
|
Rake::Task[:spec].invoke
|
|
25
25
|
end
|
|
26
26
|
|
|
27
27
|
# Clean coverage files
|
|
28
|
-
desc
|
|
28
|
+
desc 'Clean coverage files'
|
|
29
29
|
task :clean_coverage do
|
|
30
|
-
FileUtils.rm_rf(
|
|
30
|
+
FileUtils.rm_rf('coverage/')
|
|
31
31
|
end
|
|
32
32
|
|
|
33
33
|
# Build and install gem locally
|
|
34
|
-
desc
|
|
34
|
+
desc 'Build and install gem locally'
|
|
35
35
|
task :install_local do
|
|
36
|
-
sh
|
|
37
|
-
sh
|
|
38
|
-
FileUtils.rm(Dir.glob(
|
|
36
|
+
sh 'gem build rcrewai.gemspec'
|
|
37
|
+
sh 'gem install rcrewai-*.gem'
|
|
38
|
+
FileUtils.rm(Dir.glob('rcrewai-*.gem'))
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
# Run all tests and checks
|
|
42
|
-
desc
|
|
42
|
+
desc 'Run all tests and code quality checks'
|
|
43
43
|
task :ci do
|
|
44
|
-
puts
|
|
44
|
+
puts 'Running RSpec tests...'
|
|
45
45
|
Rake::Task[:spec].invoke
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
puts "\nRunning RuboCop..."
|
|
48
48
|
Rake::Task[:rubocop].invoke
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
puts "\nAll checks passed! ✅"
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
# Console task for development
|
|
54
|
-
desc
|
|
54
|
+
desc 'Start interactive console with gem loaded'
|
|
55
55
|
task :console do
|
|
56
|
-
require
|
|
57
|
-
require_relative
|
|
56
|
+
require 'irb'
|
|
57
|
+
require_relative 'lib/rcrewai'
|
|
58
58
|
IRB.start
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
# Generate documentation
|
|
62
|
-
desc
|
|
62
|
+
desc 'Generate documentation'
|
|
63
63
|
task :docs do
|
|
64
|
-
sh
|
|
65
|
-
puts
|
|
64
|
+
sh 'yard doc lib/**/*.rb'
|
|
65
|
+
puts 'Documentation generated in doc/ directory'
|
|
66
66
|
end
|
|
67
67
|
|
|
68
68
|
# Benchmark task
|
|
69
|
-
desc
|
|
69
|
+
desc 'Run performance benchmarks'
|
|
70
70
|
task :benchmark do
|
|
71
|
-
require_relative
|
|
72
|
-
|
|
71
|
+
require_relative 'lib/rcrewai'
|
|
72
|
+
|
|
73
73
|
# Simple benchmark example
|
|
74
|
-
require
|
|
75
|
-
|
|
74
|
+
require 'benchmark'
|
|
75
|
+
|
|
76
76
|
RCrewAI.configure do |config|
|
|
77
77
|
config.llm_provider = :openai
|
|
78
|
-
config.api_key =
|
|
78
|
+
config.api_key = 'test-key'
|
|
79
79
|
end
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
agent = RCrewAI::Agent.new(
|
|
82
|
-
name:
|
|
83
|
-
role:
|
|
84
|
-
goal:
|
|
82
|
+
name: 'benchmark_agent',
|
|
83
|
+
role: 'Test Agent',
|
|
84
|
+
goal: 'Run benchmarks'
|
|
85
85
|
)
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
task = RCrewAI::Task.new(
|
|
88
|
-
name:
|
|
89
|
-
description:
|
|
88
|
+
name: 'benchmark_task',
|
|
89
|
+
description: 'Test task',
|
|
90
90
|
agent: agent
|
|
91
91
|
)
|
|
92
|
-
|
|
93
|
-
crew = RCrewAI::Crew.new(
|
|
92
|
+
|
|
93
|
+
crew = RCrewAI::Crew.new('benchmark_crew')
|
|
94
94
|
crew.add_agent(agent)
|
|
95
95
|
crew.add_task(task)
|
|
96
|
-
|
|
96
|
+
|
|
97
97
|
puts "\nBenchmarking crew creation and setup..."
|
|
98
98
|
result = Benchmark.measure do
|
|
99
99
|
100.times do
|
|
100
100
|
test_crew = RCrewAI::Crew.new("test_#{rand(1000)}")
|
|
101
101
|
test_agent = RCrewAI::Agent.new(
|
|
102
|
-
name:
|
|
103
|
-
role:
|
|
104
|
-
goal:
|
|
102
|
+
name: 'test_agent',
|
|
103
|
+
role: 'Test Agent',
|
|
104
|
+
goal: 'Test performance'
|
|
105
105
|
)
|
|
106
106
|
test_crew.add_agent(test_agent)
|
|
107
107
|
end
|
|
108
108
|
end
|
|
109
|
-
|
|
109
|
+
|
|
110
110
|
puts "Created 100 crews with agents in: #{result.real.round(4)}s"
|
|
111
111
|
end
|
|
112
112
|
|
|
113
113
|
# Development setup
|
|
114
|
-
desc
|
|
114
|
+
desc 'Set up development environment'
|
|
115
115
|
task :setup do
|
|
116
|
-
puts
|
|
117
|
-
|
|
116
|
+
puts 'Setting up development environment...'
|
|
117
|
+
|
|
118
118
|
# Install dependencies
|
|
119
|
-
sh
|
|
120
|
-
|
|
119
|
+
sh 'bundle install'
|
|
120
|
+
|
|
121
121
|
# Create necessary directories
|
|
122
|
-
FileUtils.mkdir_p(
|
|
123
|
-
FileUtils.mkdir_p(
|
|
124
|
-
FileUtils.mkdir_p(
|
|
125
|
-
|
|
122
|
+
FileUtils.mkdir_p('spec/vcr_cassettes') unless Dir.exist?('spec/vcr_cassettes')
|
|
123
|
+
FileUtils.mkdir_p('coverage') unless Dir.exist?('coverage')
|
|
124
|
+
FileUtils.mkdir_p('doc') unless Dir.exist?('doc')
|
|
125
|
+
|
|
126
126
|
puts "\n✅ Development environment set up successfully!"
|
|
127
127
|
puts "\nRun 'rake spec' to run tests"
|
|
128
128
|
puts "Run 'rake console' to start an interactive session"
|
|
129
129
|
puts "Run 'rake ci' to run all checks"
|
|
130
|
-
end
|
|
130
|
+
end
|
data/bin/rcrewai
CHANGED
data/docs/mcp.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# MCP (Model Context Protocol) Support
|
|
2
|
+
|
|
3
|
+
RCrewAI 0.3 ships a minimal MCP client that lets your agents call tools
|
|
4
|
+
hosted by any MCP server — local processes (stdio) or remote services
|
|
5
|
+
(streamable HTTP) — without any custom adapter code.
|
|
6
|
+
|
|
7
|
+
## What is MCP?
|
|
8
|
+
|
|
9
|
+
[MCP](https://modelcontextprotocol.io) is an open protocol for connecting
|
|
10
|
+
language models to tools and data sources. Servers expose tools via a
|
|
11
|
+
JSON-RPC schema; clients (like RCrewAI) connect, discover the tools, and
|
|
12
|
+
invoke them on the model's behalf.
|
|
13
|
+
|
|
14
|
+
The big win: any of the dozens of off-the-shelf MCP servers — filesystem,
|
|
15
|
+
git, Slack, Postgres, browser automation, custom internal tools — works
|
|
16
|
+
with RCrewAI without writing a single line of glue.
|
|
17
|
+
|
|
18
|
+
## Connecting
|
|
19
|
+
|
|
20
|
+
### Stdio (local subprocess)
|
|
21
|
+
|
|
22
|
+
```ruby
|
|
23
|
+
require 'rcrewai'
|
|
24
|
+
|
|
25
|
+
RCrewAI::MCP::Client.with_connection(
|
|
26
|
+
command: "npx",
|
|
27
|
+
args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
|
|
28
|
+
) do |client|
|
|
29
|
+
puts "connected to #{client.server_name}"
|
|
30
|
+
client.tools.each { |t| puts " - #{t.name}: #{t.description}" }
|
|
31
|
+
end
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Streamable HTTP (remote)
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
RCrewAI::MCP::Client.with_connection(
|
|
38
|
+
url: "https://mcp.example.com/v1",
|
|
39
|
+
headers: { "Authorization" => "Bearer #{ENV['MCP_TOKEN']}" }
|
|
40
|
+
) do |client|
|
|
41
|
+
# ...
|
|
42
|
+
end
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Manual lifecycle
|
|
46
|
+
|
|
47
|
+
`with_connection` is the recommended form (auto-closes on block exit), but
|
|
48
|
+
you can also drive the lifecycle manually:
|
|
49
|
+
|
|
50
|
+
```ruby
|
|
51
|
+
client = RCrewAI::MCP::Client.connect(command: "ruby", args: ["my_server.rb"])
|
|
52
|
+
# ... use client.tools ...
|
|
53
|
+
client.close
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Tool name prefix
|
|
57
|
+
|
|
58
|
+
To prevent collisions when an agent uses tools from multiple MCP servers,
|
|
59
|
+
tool names are prefixed with the server name:
|
|
60
|
+
|
|
61
|
+
```
|
|
62
|
+
echo-server__echo
|
|
63
|
+
filesystem__read_file
|
|
64
|
+
filesystem__write_file
|
|
65
|
+
git__commit
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
The prefix is `#{server_name}__#{tool_name}`, where `server_name` comes
|
|
69
|
+
from the server's own `serverInfo.name`.
|
|
70
|
+
|
|
71
|
+
## Using MCP tools with an agent
|
|
72
|
+
|
|
73
|
+
MCP tools are ordinary `RCrewAI::Tools::Base` instances — pass them to
|
|
74
|
+
`Agent.new(tools: ...)` like any other tool:
|
|
75
|
+
|
|
76
|
+
```ruby
|
|
77
|
+
RCrewAI::MCP::Client.with_connection(command: "npx", args: [...]) do |client|
|
|
78
|
+
agent = RCrewAI::Agent.new(
|
|
79
|
+
name: "fs_agent",
|
|
80
|
+
role: "Filesystem operator",
|
|
81
|
+
goal: "Read and summarize files",
|
|
82
|
+
tools: client.tools
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
task = RCrewAI::Task.new(name: "summarize",
|
|
86
|
+
description: "Read /tmp/notes.md and summarize",
|
|
87
|
+
agent: agent)
|
|
88
|
+
result = agent.execute_task(task)
|
|
89
|
+
puts result[:content]
|
|
90
|
+
end
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
When `ToolRunner` (the new native-function-calling loop) is selected, the
|
|
94
|
+
LLM picks an MCP tool by name, RCrewAI dispatches the call to the MCP
|
|
95
|
+
server, threads the result back into the conversation, and continues.
|
|
96
|
+
|
|
97
|
+
## What's not (yet) supported in 0.3
|
|
98
|
+
|
|
99
|
+
The 0.3 client is intentionally minimal — it covers `initialize`,
|
|
100
|
+
`tools/list`, `tools/call`, and the `notifications/initialized` handshake.
|
|
101
|
+
The following are not implemented:
|
|
102
|
+
|
|
103
|
+
- **Resources** (`resources/list`, `resources/read`)
|
|
104
|
+
- **Prompts** (`prompts/list`, `prompts/get`)
|
|
105
|
+
- **Server mode** — RCrewAI can be an MCP client, not yet an MCP server
|
|
106
|
+
- **OAuth** authentication for HTTP transports
|
|
107
|
+
- **Notifications other than `initialized`** (e.g., progress, log)
|
|
108
|
+
|
|
109
|
+
These will land in follow-up releases as the MCP spec stabilizes.
|