secondbrainos-mcp-server
v1.0.9
Published
Second Brain OS MCP Server for Claude Desktop
Maintainers
Readme
Second Brain OS MCP Server
This package provides a Model Context Protocol (MCP) server for integrating Second Brain OS with Claude Desktop.
Prerequisites
- Node.js v16 or higher
- Claude Desktop application
- A valid Second Brain OS account with the Claude MCP feature enabled
Installation
npm install -g secondbrainos-mcp-serverUsage
After installation, run the setup command with your USER_ID and USER_SECRET:
secondbrainos-mcp USER_ID USER_SECRETThis will:
- Verify your account credentials
- Confirm you have access to the Claude MCP feature
- Create the necessary configuration files for Claude Desktop
- Configure the server to dynamically fetch your available API endpoints
Features
Enhanced OpenAPI Support
The server uses @samchon/openapi library for robust OpenAPI handling, providing:
- Support for all OpenAPI/Swagger versions (v2.0, v3.0, v3.1)
- Automatic schema conversion to a standardized format
- Better handling of complex schemas including references, nullable properties, and union types
Improved Function Execution
- Type-safe function execution with built-in error handling
- Automatic request formatting based on OpenAPI specifications
- Support for complex parameters and nested objects
Prompts (Workflows)
The server exposes your Second Brain OS workflows as MCP prompts, making them available in Claude Desktop's attach menu:
- Automatically discovers your workflows via the
runPromptChainservice - Each workflow appears as a selectable prompt with its name and description
- Selecting a prompt fetches the full prompt chain (ordered instructions) and injects them into the conversation
- Supports an optional
user_inputargument to provide additional context
Better Error Handling
- Detailed error messages for debugging
- Proper handling of authentication failures, bad requests, and service errors
- Graceful fallback for unexpected errors
Development
Setup
- Clone the repository:
git clone https://github.com/your-username/secondbrainos-mcp-server.git
cd secondbrainos-mcp-server- Install dependencies:
npm install- Create a
.envfile from the example:
cp .env.example .env
# Edit .env with your actual USER_ID and USER_SECRETTesting the Schema Conversion
To see how your OpenAPI schema is converted to MCP tools:
npm run test-conversionThis will:
- Fetch your OpenAPI schema from Second Brain OS
- Convert it to LLM function calling format
- Display all available functions and their schemas
- Show any conversion errors
- Demonstrate the MCP tool format
Development Scripts
npm run build- Compile TypeScript to JavaScriptnpm run dev- Run the MCP server in development modenpm run test-conversion- Test the OpenAPI to MCP conversionnpm start- Run the compiled server
Project Structure
secondbrainos-mcp-server/
├── src/
│ ├── index.ts # Main MCP server implementation
│ └── test-conversion.ts # Schema conversion testing utility
├── build/ # Compiled JavaScript (git-ignored)
├── bin/
│ └── cli.js # CLI setup script
├── .env.example # Environment variables template
├── package.json # Package configuration
├── tsconfig.json # TypeScript configuration
└── README.md # This fileEnvironment Variables
The server requires the following environment variables:
USER_ID: Your Second Brain OS user IDUSER_SECRET: Your Second Brain OS user secretAPI_BASE_URL(optional): Override the default API base URL
How It Works
- Schema Fetching: On startup, the server fetches your personalized OpenAPI schema from Second Brain OS
- Schema Conversion: The
@samchon/openapilibrary converts the schema to an optimized format for LLM function calling - MCP Tools: Each API endpoint becomes an MCP tool that Claude can use
- MCP Prompts: If the
runPromptChainservice is available, your workflows are exposed as selectable prompts in the client UI - Function Execution: When Claude calls a tool, the server executes the corresponding API call with proper authentication
Troubleshooting
Claude Desktop doesn't see the server
- Ensure Claude Desktop is completely quit before running the setup
- Check the configuration file was created at the correct location
- Review the logs at the platform-specific location mentioned during setup
Authentication errors
- Verify your USER_ID and USER_SECRET are correct
- Ensure your account has the Claude MCP feature enabled
- Check that your credentials haven't expired
Schema conversion errors
- Run
npm run test-conversionto see detailed error messages - Some complex OpenAPI features may not be supported by LLM function calling
- Check the console output for specific endpoints that failed conversion
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
MIT
