8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/action_mcp/server/completions.rb', line 8
def send_completion_complete(request_id, params)
unless completion_capability?
send_jsonrpc_error(request_id, :method_not_found, "Completions are not available for this session")
return
end
if (validation_error = ProtocolValidator.request_params_validation_error("completion/complete", params))
send_jsonrpc_error(request_id, validation_error.code, validation_error.message)
return
end
params = params.with_indifferent_access
definition = completion_definition(params[:ref], params.dig(:argument, :name))
unless definition
send_jsonrpc_error(request_id, :invalid_params, "Unknown completion reference or argument")
return
end
values = matching_completion_values(definition, params.dig(:argument, :value))
result = {
completion: {
values: values.first(MAX_COMPLETION_VALUES),
total: values.length,
hasMore: values.length > MAX_COMPLETION_VALUES
}
}
send_jsonrpc_response(request_id, result: result)
end
|