Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] MCP prompts #639

Closed
wants to merge 3 commits into from
Closed

[feat] MCP prompts #639

wants to merge 3 commits into from

Conversation

ahau-square
Copy link
Collaborator

Implement get_prompt and list_prompts per MCP: https://spec.modelcontextprotocol.io/specification/2024-11-05/server/prompts/

  • add a prompts.rs to goose-server/routes with additional /prompts/list and /prompts/get/:prompt_name routes that call the passthrough respectively
  • implement passthrough in agents
  • add the list_prompts and get_prompt declarations on the mcpclienttrait
  • implement list_prompts and get_prompt in mcp-client/client.rs

Copy link
Collaborator

@baxen baxen left a comment

Choose a reason for hiding this comment

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

Looks good!

let client = capabilities
.get_system(system)
.await
.unwrap_or_else(|| panic!("System not found: {}", system));
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we should return an Err (SystemError::UnknownSystem) here instead of panicing?

async fn passthrough(&self, _system: &str, _request: Value) -> SystemResult<Value> {
// TODO implement
Ok(Value::Null)
async fn passthrough(&self, system: &str, method: &str, params: Value) -> SystemResult<Value> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

meganit: maybe implement self.capabilities.passthrough helper - i think this code would be the same throughout

@@ -314,4 +314,10 @@ impl Capabilities {

result
}

/// Retrieve a client by name, if it exists
pub async fn get_system(&self, system: &str) -> Option<Arc<Mutex<Box<dyn McpClientTrait>>>> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: for clarity get_client to match get_client_for_tool?

Copy link
Collaborator

@wendytang wendytang left a comment

Choose a reason for hiding this comment

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

nice!!

Copy link
Collaborator

@wendytang wendytang left a comment

Choose a reason for hiding this comment

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

cargo run --bin goosed -- agent

curl --request POST \
  --url http://127.0.0.1:3000/prompts/list \
  --header 'Content-Type: application/json' \
  --header 'X-Secret-Key: test' \
  --data '{
    "system": "developer"
  }'

This hangs for me though

@wendytang
Copy link
Collaborator

ported over here ahau/wtang/prompts, #668 needs to be merged

@alicehau alicehau closed this Feb 11, 2025
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.

4 participants