bringcontext
v0.5.1
Published
Knowledge retrieval tool operating according to the Model Context Protocol (MCP)
Readme
BringContext MCP Server
A powerful knowledge retrieval tool operating according to the Model Context Protocol (MCP). BringContext enhances Large Language Models by providing access to external knowledge sources on demand.
🚀 Overview
BringContext simulates a simplified version of Retrieval Augmented Generation (RAG), enabling LLMs to dynamically fetch information from external knowledge bases, resulting in more accurate, context-aware responses. It is designed for a zero-installation experience using npx.
Core Features
- 📚 Provides LLMs with access to external knowledge sources through the Model Context Protocol
- 🔍 Dynamically registers
.txtfiles in a global knowledge base directory in your home folder (~/.bringcontext/) as MCP resources. - 🏠 Uses a persistent global knowledge base that survives package updates and reinstalls
- 🛠️ Simple integration with MCP clients like Cursor, Cline, and Claude Desktop
- 💡
.txtfiles in your knowledge base become available as resources. - ✨ Zero-setup:
npx bringcontextautomatically creates the knowledge base directory if it doesn't exist and outputs the recommended client configuration.
📋 Requirements
- Node.js (version 16.x or higher)
- npm (comes with Node.js)
- An MCP-compatible client (Cursor, Cline, Claude Desktop, or any client supporting STDIO transport)
🛠️ Quick Start
BringContext is designed to be run exclusively using npx bringcontext. The first time you run this command, it will automatically create the global knowledge base directory at ~/.bringcontext/ if it doesn't already exist. It will also output the recommended client configuration to your terminal.
# Run BringContext MCP Server via npx
npx bringcontext🔧 Knowledge Base
BringContext uses a simple one-file-one-tool approach. Each .txt file in your global knowledge base directory (~/.bringcontext/) becomes an available tool for LLMs to use.
Knowledge Base Location
BringContext stores its knowledge base in a global directory in your home folder:
- Windows:
C:\Users\<username>\.bringcontext - macOS/Linux:
/home/<username>/.bringcontext
This global location ensures your knowledge base:
- Persists across package updates and reinstalls
- Is consistent across all your projects
- Is easily accessible from any directory
The npx bringcontext command automatically creates this directory if it doesn't exist.
Adding Your Own Tools
Adding a new tool is as simple as creating a .txt file in your knowledge base directory (~/.bringcontext/):
Run
npx bringcontextonce to ensure the~/.bringcontextdirectory is created.Create a new text file with a descriptive name (e.g.,
company-history.txt) in the~/.bringcontext/directory.echo "My company was founded in 2020" > ~/.bringcontext/company-history.txt(Note: On Windows, you might need to use a different command like
echo "My company was founded in 2020" > %USERPROFILE%\.bringcontext\company-history.txtin Command Prompt orecho "My company was founded in 2020" | Out-File -Path ~/.bringcontext/company-history.txtin PowerShell)That's it! The next time your MCP client launches BringContext via
npx bringcontext, acompany-historytool will be automatically available to LLMs.
The tool name will be exactly the same as the filename (without the .txt extension).
🚀 Usage
Running the Server
Run the server using the npx bringcontext command. This command handles the initial setup of the knowledge base directory, outputs the client configuration, and starts the MCP server.
# Run BringContext MCP Server via npx
npx bringcontextMCP Client Configuration
Configure your MCP client to launch the BringContext server using the npx bringcontext command. For Windows clients, a workaround using cmd /c is necessary due to known issues with npx execution in some environments. Running npx bringcontext will output the recommended configuration snippet to your terminal for easy copying.
Example MCP Configuration
Here's an example configuration for your MCP client (includes Windows workaround):
{
"mcpServers": {
"bringcontext": {
"command": "cmd",
"args": [
"/c",
"npx",
"-y",
"bringcontext"
]
}
}
}Add this configuration to your client's settings (e.g., .cursor/settings.json for Cursor, or the MCP settings in Cline/Claude Desktop).
🗂️ Directory Structure
When you use BringContext, the relevant directory structure is your global knowledge base directory:
~/.bringcontext/ # Global knowledge base directory (automatically created by npx)
├── helloworld.txt # Example knowledge base file (you can add your own .txt files here)
└── another-tool.txt # Another example user-defined toolEach .txt file in this directory becomes an available tool for LLMs to use.
🔍 How It Works
BringContext operates on a simple but powerful principle:
- When launched via
npx bringcontext, the command:- Checks if the
~/.bringcontextdirectory exists and creates it if necessary. - Outputs the recommended client configuration to standard output.
- Starts the BringContext MCP server.
- Checks if the
- The BringContext MCP server:
- Scans the
~/.bringcontextdirectory for.txtfiles. - Registers each
.txtfile as an MCP resource, using the file URI (file://<path>) as the resource identifier. Logging is added to indicate which resources are being registered. - Exposes these resources to LLMs through the MCP.
- Scans the
- When an LLM requests information using a resource URI (e.g.,
file:///path/to/company-history.txt):- BringContext locates the corresponding file (e.g.,
company-history.txt) based on the resource URI. Logging is added to indicate when a resource is requested and which file it is attempting to read. - Reads the content of the file.
- Returns the content to the LLM in the MCP resource response format.
- BringContext locates the corresponding file (e.g.,
This approach allows you to easily extend the knowledge available to LLMs by simply adding more .txt files to your knowledge base directory (~/.bringcontext/).
🛠️ Troubleshooting
Common Issues and Solutions
Knowledge Base Issues
If tools aren't appearing or the server fails to start:
- Ensure you have run
npx bringcontextat least once to create the~/.bringcontextdirectory. - If the server fails to start, verify that the
~/.bringcontextdirectory exists and that the process running the server has the necessary permissions to access and read files from it. - Check that your
.txtfiles are in the correct location (~/.bringcontext/). - Ensure the files have the
.txtextension. - Verify you have read permissions on the knowledge base directory and the files within it.
MCP Client Configuration
If your MCP client can't connect to BringContext:
- Ensure you've added the configuration to your client's settings, using the
cmd /c npx -y bringcontextcommand for Windows. - Verify that Node.js and npm are in your system's PATH.
🔮 Future Roadmap
BringContext will continue to evolve with planned enhancements, including support for different file types, advanced knowledge retrieval techniques, and knowledge base management tools.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- 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
This project is licensed under the MIT License - see the LICENSE file for details.
