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

Feature/mcp-client #473

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

glassBead-tc
Copy link
Contributor

📝 Summary

This PR integrates the Model Context Protocol (MCP) client into Srcbook. This integration significantly expands Srcbook's current and future capabilities by giving the local-first version access to a wide array of external tools and resources. Those included in the srcbook_mcp_config.example.json file require no API key or registration, meaning the community can begin building integrations with them immediately. This PR provides support for a single MCP server, sequential-thinking, implemented here with a simple on-off toggle in the dialog window during build sessions.

Importantly, MCP works only on the local dev server in this PR. Enabling MCP for local-first production will require addressing #456, and more generally, configuring Srcbook to target different builds based on the host machine's chip architecture (i.e. Intel vs Apple Silicon). I chose to keep this PR focused on the MCP integration and will address the above issue in a follow-up PR, and in the issue discussion on GitHub.

🛠 Implementation Details

  • MCP Client Integration:

    • Added MCP client configuration in packages/api/mcp/.
    • Enabled interactions between Srcbook and external tool/resource providers via MCP.
  • Enhanced AI Capabilities:

    • AI can now utilize sequential-thinking for improved problem-solving, and connect to various external services including Puppeteer and Memory.
  • Configuration Updates:

    • Updated README.md to include MCP integration details.
    • Added MCP_README.md with comprehensive setup and usage instructions.
  • Dependencies:

    • Pinned Node engine version to 20.x to ensure compatibility and stability, especially with regard to Rollup: this will become important later when implementing conditional build targeting in Docker based on whether the user's host machine runs on an Intel or ARM architecture.
    • Added new dependency: "@modelcontextprotocol/sdk": "^1.1.0".

📚 Related Documentation

  • Updated README.md:

    • Added a new line under the App Builder section to highlight MCP integration.
  • Added MCP_README.md:

    • Detailed guide on MCP integration, configuration, usage, troubleshooting, and future development.

🔗 Related Issues

🧪 Testing

  • Unit Tests: (To be added)

    • Unit tests for MCP integration are in progress. Currently, I'm looking at ways to make MCP Inspector a part of that testing suite.
  • Manual Testing:

    • Successfully integrated MCP client on the local development server.
    • Verified AI's ability to access and interact with configured data sources.
    • Tested sequential-thinking feature to ensure enhanced reasoning capabilities.
  • Demo Video:

    • A demonstration of MCP integration will be available on YouTube shortly. [Link to be added upon upload.]

📸 Screenshots/GIFs

(If applicable, insert images or GIFs here)

🔗 Additional Information

  • Dependencies:

    • New Dependency: "@modelcontextprotocol/sdk": "^1.1.0"
    • Node Engine: Pinned to 20.x to avoid compatibility issues, especially with Rollup handling different architectures.
  • Setup Instructions:

    1. Install Dependencies:
      npm install @modelcontextprotocol/sdk
    2. Configure MCP Client:
      • Navigate to packages/api/.
      • Copy srcbook_mcp_config.example.json to srcbook_mcp_config.json.
      • Update the filesystem paths in srcbook_mcp_config.json:
        {
          "mcpServers": {
            "memory": {
              "command": "npx",
              "args": ["-y", "@modelcontextprotocol/server-memory"]
            },
            "filesystem": {
              "command": "npx",
              "args": [
                "-y",
                "@modelcontextprotocol/server-filesystem",
                "/PATH/TO/YOUR/DESKTOP",
                "/PATH/TO/YOUR/DOWNLOADS"
              ]
            },
            "puppeteer": {
              "command": "npx",
              "args": ["-y", "@modelcontextprotocol/server-puppeteer"]
            },
            "sequential-thinking": {
              "command": "npx",
              "args": ["-y", "@modelcontextprotocol/server-sequential-thinking"]
            },
            "everything": {
              "command": "npx",
              "args": ["-y", "@modelcontextprotocol/server-everything"]
            },
            "mcp-installer": {
              "command": "npx",
              "args": ["@anaisbetts/mcp-installer"]
            }
          }
        }
      • Replace /PATH/TO/YOUR/DESKTOP and /PATH/TO/YOUR/DOWNLOADS with the actual paths on your machine.
    3. Run Srcbook:
      pnpm run dev

🗣️ Future Development

  • Local Production Support in Docker:

    • Addressing platform detection issues in follow-up PR.
  • Notebook Integration:

    • Expanding MCP support to notebook functionality for enhanced interactivity.
  • Additional Server Integrations:

    • Incorporating more MCP servers to extend Srcbook's capabilities further.

📽️ Demo Video

A demonstration video showcasing the MCP integration (here, with the sequential-thinking server) is available on YouTube. Link

📚 Additional Resources


Notes for Reviewers:

  1. Code Location: Most of the new code resides in the packages/api/mcp/ directory. Please focus your review on this folder to understand the MCP client implementation.

  2. Configuration Requirements: Users must update their srcbook_mcp_config.json with the correct filesystem paths to enable MCP filesystem access. Detailed instructions are provided in MCP_README.md.

  3. Pending Unit Tests: While unit tests are not yet included, they are being developed to ensure the reliability and stability of the MCP integration. Contributions or suggestions for testing strategies are welcome.


Contributors:

  • @glassBead-tc: Primary contributor for the MCP client implementation.

🎉 Conclusion

The MCP client is a significant expansion of Srcbook's potential, but more remains to be done to make it a fully functional feature, and addressing the issues around platform targeting and filesystem access is the next step in that process.

Thank you for reviewing this PR! 🙏

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.

1 participant