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: secrets configuration for mcp server #565

Open
wants to merge 3 commits into
base: v1.0
Choose a base branch
from

Conversation

salman1993
Copy link
Collaborator

@salman1993 salman1993 commented Jan 9, 2025

tested with Tavily MCP Server for web search:

  1. build and run goosed: cargo run --bin goosed -- agent

  2. add system with secret. you need to replace with free API key that you can get here: https://app.tavily.com/home

curl --request POST \
  --url http://localhost:3000/systems/add \
  --header 'Content-Type: application/json' \
  --data '{
  "type": "Stdio",
  "cmd": "uvx", 
  "args": ["mcp-tavily"], 
  "secrets": {
    "TAVILY_API_KEY": "REPLACE_SECRET_HERE"
  }
}'
  1. ask question that requires using the system's tools
curl --request POST \
  --url http://localhost:3000/ask \
  --header 'Content-Type: application/json' \
  --data '{
  "prompt": "can you do a search for recent news on LA wildfires - give me a timeline of events if possible. only provide breaking news and also let me know which tools you called in the process of getting the answer. be very concise!"
}'

Screenshot 2025-01-09 at 1 34 19 PM

step (2) validation depends on MCP server implementation - eg. it fails if env var is not set but does not fail if you set an invalid key - in that case, it will fail in step (3) by replying it can't get the news, which isn't good.

We can prompt the LLM to let the user know if the system contains secrets but its tools can't be used.

Copy link

github-actions bot commented Jan 9, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

@@ -15,25 +17,56 @@ pub enum SystemError {

pub type SystemResult<T> = Result<T, SystemError>;

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct Secrets {
/// A map of environment variables to set, e.g. API_KEY -> some_secret
Copy link
Collaborator Author

@salman1993 salman1993 Jan 9, 2025

Choose a reason for hiding this comment

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

this right now stores the secret in plaintext. this can also be a map of env_var_name -> key_manager_secret_name and then we pull in the secret value and set it as env var

pub fn get_keyring_secret(


pub fn set_environment_vars(&self) {
for (key, value) in &self.map {
std::env::set_var(key, value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this looks like it sets the env vars for the main goose process, should we only be setting the secrets in for the subprocess when doing stdio mcps servers?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a good question. there is a TODO on adding in-process transport. for now, it makes sense to set it in only in subprocess -

// TODO once the client/server for MCP has stabilized, we should probably add InProcess transport to each

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

updated this to be set envs in the spawned process

Copy link

github-actions bot commented Jan 9, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

}
}

async fn spawn_process(&self) -> Result<(Child, ChildStdin, ChildStdout), Error> {
let mut process = Command::new(&self.command)
.envs(&self.env)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this do any validation for us to make sure the values passed are valid as environment vars? Names etc. Would be nice to get some descriptive messages if anything goes wrong.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this totally depends on the server implementation. in the case of the Tavily example: it errors if TAVILY_API_KEY is not set but it won't error if its an invalid key

Copy link

github-actions bot commented Jan 9, 2025

Desktop App for this PR

The following build is available for testing:

The app is signed and notarized for macOS. After downloading, unzip the file and drag the Goose.app to your Applications folder.

This link is provided by nightly.link and will work even if you're not logged into GitHub.

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