Skip to content

Commit e4d305c

Browse files
committed
addedd note about pagination in the readme
1 parent 511647f commit e4d305c

25 files changed

+1584
-96
lines changed

README.md

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -229,23 +229,6 @@ content = log_template.to_content(arguments: {
229229
puts content
230230
```
231231

232-
#### Resource Argument Completion
233-
234-
For resource templates, you can get suggested values for arguments:
235-
236-
```ruby
237-
template = client.resource_template("user_profile")
238-
239-
# Search for possible values for a specific argument
240-
suggestions = template.complete("username", "john")
241-
puts "Suggested usernames:"
242-
suggestions.values.each do |value|
243-
puts "- #{value}"
244-
end
245-
puts "Total matches: #{suggestions.total}"
246-
puts "Has more: #{suggestions.has_more}"
247-
```
248-
249232
### Working with Prompts
250233

251234
MCP servers can provide predefined prompts that can be used in conversations:
@@ -308,7 +291,7 @@ response = chat.ask("Please review the recent commits using the checklist and su
308291
puts response
309292
```
310293

311-
## Argument Completion
294+
### Argument Completion
312295

313296
Some MCP servers support argument completion for prompts and resource templates:
314297

@@ -325,7 +308,13 @@ puts "Total matches: #{suggestions.total}"
325308
puts "Has more results: #{suggestions.has_more}"
326309
```
327310

328-
## Additional Chat Methods
311+
### Pagination
312+
313+
MCP servers can support pagination for their lists. The client will automatically paginate the lists to include all items from the list you wanted to pull.
314+
315+
Pagination is supported for tools, resources, prompts, and resource templates.
316+
317+
### Additional Chat Methods
329318

330319
The gem extends RubyLLM's chat interface with convenient methods for MCP integration:
331320

lib/ruby_llm/mcp/coordinator.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def start_transport
5151
@transport.set_protocol_version(@protocol_version)
5252
end
5353

54-
@capabilities = RubyLLM::MCP::Capabilities.new(initialize_response.value["capabilities"])
54+
@capabilities = RubyLLM::MCP::ServerCapabilities.new(initialize_response.value["capabilities"])
5555
initialize_notification
5656
end
5757

@@ -103,7 +103,7 @@ def tool_list(cursor: nil)
103103
result.raise_error! if result.error?
104104

105105
if result.next_cursor?
106-
result.value["tools"] + tool_list(next_cursor: result.next_cursor)
106+
result.value["tools"] + tool_list(cursor: result.next_cursor)
107107
else
108108
result.value["tools"]
109109
end
@@ -134,7 +134,7 @@ def resource_list(cursor: nil)
134134
result.raise_error! if result.error?
135135

136136
if result.next_cursor?
137-
result.value["resources"] + resource_list(next_cursor: result.next_cursor)
137+
result.value["resources"] + resource_list(cursor: result.next_cursor)
138138
else
139139
result.value["resources"]
140140
end
@@ -149,7 +149,7 @@ def resource_template_list(cursor: nil)
149149
result.raise_error! if result.error?
150150

151151
if result.next_cursor?
152-
result.value["resourceTemplates"] + resource_template_list(next_cursor: result.next_cursor)
152+
result.value["resourceTemplates"] + resource_template_list(cursor: result.next_cursor)
153153
else
154154
result.value["resourceTemplates"]
155155
end
@@ -164,7 +164,7 @@ def prompt_list(cursor: nil)
164164
result.raise_error! if result.error?
165165

166166
if result.next_cursor?
167-
result.value["prompts"] + prompt_list(next_cursor: result.next_cursor)
167+
result.value["prompts"] + prompt_list(cursor: result.next_cursor)
168168
else
169169
result.value["prompts"]
170170
end

lib/ruby_llm/mcp/requests/initialization.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def initialize_body
1919
jsonrpc: "2.0",
2020
method: "initialize",
2121
params: {
22-
protocolVersion: coordinator.protocol_version,
23-
capabilities: coordinator.client_capabilities,
22+
protocolVersion: @coordinator.protocol_version,
23+
capabilities: @coordinator.client_capabilities,
2424
clientInfo: {
2525
name: "RubyLLM-MCP Client",
2626
version: RubyLLM::MCP::VERSION

lib/ruby_llm/mcp/result.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def notification?
6868
end
6969

7070
def next_cursor?
71-
@next_cursor.present?
71+
!@next_cursor.nil?
7272
end
7373

7474
def request?
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
module RubyLLM
44
module MCP
5-
class Capabilities
5+
class ServerCapabilities
66
attr_accessor :capabilities
77

88
def initialize(capabilities = {})
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
2+
3+
# Logs
4+
5+
logs
6+
_.log
7+
npm-debug.log_
8+
yarn-debug.log*
9+
yarn-error.log*
10+
lerna-debug.log*
11+
.pnpm-debug.log*
12+
13+
# Caches
14+
15+
.cache
16+
17+
# Diagnostic reports (https://nodejs.org/api/report.html)
18+
19+
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
20+
21+
# Runtime data
22+
23+
pids
24+
_.pid
25+
_.seed
26+
*.pid.lock
27+
28+
# Directory for instrumented libs generated by jscoverage/JSCover
29+
30+
lib-cov
31+
32+
# Coverage directory used by tools like istanbul
33+
34+
coverage
35+
*.lcov
36+
37+
# nyc test coverage
38+
39+
.nyc_output
40+
41+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
42+
43+
.grunt
44+
45+
# Bower dependency directory (https://bower.io/)
46+
47+
bower_components
48+
49+
# node-waf configuration
50+
51+
.lock-wscript
52+
53+
# Compiled binary addons (https://nodejs.org/api/addons.html)
54+
55+
build/Release
56+
57+
# Dependency directories
58+
59+
node_modules/
60+
jspm_packages/
61+
62+
# Snowpack dependency directory (https://snowpack.dev/)
63+
64+
web_modules/
65+
66+
# TypeScript cache
67+
68+
*.tsbuildinfo
69+
70+
# Optional npm cache directory
71+
72+
.npm
73+
74+
# Optional eslint cache
75+
76+
.eslintcache
77+
78+
# Optional stylelint cache
79+
80+
.stylelintcache
81+
82+
# Microbundle cache
83+
84+
.rpt2_cache/
85+
.rts2_cache_cjs/
86+
.rts2_cache_es/
87+
.rts2_cache_umd/
88+
89+
# Optional REPL history
90+
91+
.node_repl_history
92+
93+
# Output of 'npm pack'
94+
95+
*.tgz
96+
97+
# Yarn Integrity file
98+
99+
.yarn-integrity
100+
101+
# dotenv environment variable files
102+
103+
.env
104+
.env.development.local
105+
.env.test.local
106+
.env.production.local
107+
.env.local
108+
109+
# parcel-bundler cache (https://parceljs.org/)
110+
111+
.parcel-cache
112+
113+
# Next.js build output
114+
115+
.next
116+
out
117+
118+
# Nuxt.js build / generate output
119+
120+
.nuxt
121+
dist
122+
123+
# Gatsby files
124+
125+
# Comment in the public line in if your project uses Gatsby and not Next.js
126+
127+
# https://nextjs.org/blog/next-9-1#public-directory-support
128+
129+
# public
130+
131+
# vuepress build output
132+
133+
.vuepress/dist
134+
135+
# vuepress v2.x temp and cache directory
136+
137+
.temp
138+
139+
# Docusaurus cache and generated files
140+
141+
.docusaurus
142+
143+
# Serverless directories
144+
145+
.serverless/
146+
147+
# FuseBox cache
148+
149+
.fusebox/
150+
151+
# DynamoDB Local files
152+
153+
.dynamodb/
154+
155+
# TernJS port file
156+
157+
.tern-port
158+
159+
# Stores VSCode versions used for testing VSCode extensions
160+
161+
.vscode-test
162+
163+
# yarn v2
164+
165+
.yarn/cache
166+
.yarn/unplugged
167+
.yarn/build-state.yml
168+
.yarn/install-state.gz
169+
.pnp.*
170+
171+
# IntelliJ based IDEs
172+
.idea
173+
174+
# Finder (MacOS) folder config
175+
.DS_Store

0 commit comments

Comments
 (0)