Skip to content

Completion complete - #121

Open
cafalchio wants to merge 3 commits into
mainfrom
completion_complete
Open

Completion complete#121
cafalchio wants to merge 3 commits into
mainfrom
completion_complete

Conversation

@cafalchio

Copy link
Copy Markdown
Contributor

Added support for completions.
Conformance test is passing.

Completion tests are still marked are ignored as they are dependent on list_prompt and list_resources.

Signed-off-by: cafalchio <mcafalchio@gmail.com>
Signed-off-by: cafalchio <mcafalchio@gmail.com>
Signed-off-by: Matheus <mcafalchio@gmail.com>

@lucarlig lucarlig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes: completion routing uses the wrong table, rewrites the wrong field, and is not advertised through discovery; please also enable a positive dataplane-only test.

Comment on lines +24 to +42
let Some(downstream_name) = (match &request.r#ref {
Reference::Prompt(_) => request.r#ref.as_prompt_name(),
Reference::Resource(_) => request.r#ref.as_resource_uri(),
_ => None,
}) else {
return Err(ErrorData {
code: ErrorCode::INVALID_PARAMS,
message: "Routing problem... completion not found".into(),
data: None,
});
};

let Some(route) = virtual_host.tools.get(downstream_name) else {
return Err(ErrorData {
code: ErrorCode::INVALID_PARAMS,
message: "Routing problem... tool not found".into(),
data: None,
});
};

@lucarlig lucarlig Sep 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Completion references are keyed in the prompt/resource routing tables, so looking them up in tools makes every valid completion return tool not found.

Suggested change
let Some(downstream_name) = (match &request.r#ref {
Reference::Prompt(_) => request.r#ref.as_prompt_name(),
Reference::Resource(_) => request.r#ref.as_resource_uri(),
_ => None,
}) else {
return Err(ErrorData {
code: ErrorCode::INVALID_PARAMS,
message: "Routing problem... completion not found".into(),
data: None,
});
};
let Some(route) = virtual_host.tools.get(downstream_name) else {
return Err(ErrorData {
code: ErrorCode::INVALID_PARAMS,
message: "Routing problem... tool not found".into(),
data: None,
});
};
let route = match &request.r#ref {
Reference::Prompt(prompt) => virtual_host.prompts.get(&prompt.name),
Reference::Resource(resource) => virtual_host
.resource_templates
.get(&resource.uri)
.or_else(|| virtual_host.resources.get(&resource.uri)),
_ => None,
};
let Some(route) = route else {
return Err(ErrorData {
code: ErrorCode::INVALID_PARAMS,
message: "Routing problem... completion not found".into(),
data: None,
});
};

let mut backend_service = connect_backend_for_request(mcp_service, &backend_name, backend, &cx).await?;

let mut routed_request = request;
routed_request.argument.name = completion_name;

@lucarlig lucarlig Sep 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

argument.name is the parameter being completed, so replacing it with the backend identifier leaves the namespaced ref unchanged and makes the backend reject the request.

Suggested change
routed_request.argument.name = completion_name;
match &mut routed_request.r#ref {
Reference::Prompt(prompt) => prompt.name = completion_name,
Reference::Resource(resource) => resource.uri = completion_name,
_ => {},
}

use super::McpService;

#[allow(clippy::unused_async)]
pub(super) async fn complete(

@lucarlig lucarlig Sep 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

server/discover currently advertises no completions capability, so capability-aware clients will never invoke this handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants