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(@mastra/mcp): MCPConfiguration class #2845

Merged
merged 20 commits into from
Mar 10, 2025
Merged

Conversation

TylerBarnes
Copy link
Contributor

@TylerBarnes TylerBarnes commented Mar 8, 2025

This PR:

  1. Adds the new MCPConfiguration class from https://github.com/mastra-ai/mastra/blob/main/explorations/mcp-registry-client/README.md (minus the registry part)
  2. tests for new class
  3. updates docs, adds a code example (will add an example docs page next week). shows using tools vs toolsets and why/when you would use each
  4. fixed a couple bugs in MastraMCPClient class
    • Passing server.env config would break commands like npx since PATH wasn't being passed in
    • There was no graceful shutdown when the process exited - so code saves would print massive errors from mcp servers when running mastra dev

Example:

const mcp = new MCPConfiguration({
  servers: {
    stockPrice: {
      command: 'npx',
      args: ['-y', 'tsx', './src/mastra/tools/stock-price.ts'],
      env: {
        FAKE_CREDS: 'let me in!',
      },
    },
    weather: {
      url: new URL('http://localhost:8080/sse'),
    },
  },
});

const toolsets = await mcp.getConnectedToolsets();
const tools = await mcp.getConnectedTools();

screenshot from running the cli code example (also works with mastra dev)
Screenshot 2025-03-07 at 4 38 50 PM

Copy link

codesandbox bot commented Mar 8, 2025

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

Copy link

changeset-bot bot commented Mar 8, 2025

🦋 Changeset detected

Latest commit: 5874164

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
mastra Minor
@mastra/mcp Minor
@mastra/dane Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Mar 8, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
assistant-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 10:00pm
bird-checker ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 10:00pm
crypto-chatbot ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 10:00pm
mastra-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 10:00pm
openapi-spec-writer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 10, 2025 10:00pm
travel-ai ❌ Failed (Inspect) Mar 10, 2025 10:00pm

Copy link

promptless bot commented Mar 8, 2025

📝 Documentation updates detected! You can review documentation updates here

@vercel vercel bot temporarily deployed to Preview – openapi-spec-writer March 8, 2025 01:28 Inactive
@vercel vercel bot temporarily deployed to Preview – bird-checker March 8, 2025 01:28 Inactive
@vercel vercel bot temporarily deployed to Preview – crypto-chatbot March 8, 2025 01:28 Inactive
@vercel vercel bot temporarily deployed to Preview – travel-ai March 8, 2025 01:28 Inactive
Copy link
Contributor

github-actions bot commented Mar 10, 2025

Braintrust eval report

No experiments to report

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.

2 participants