mcp-leveldb
mcp-leveldb is a wrapper library for LevelDB implemented in TypeScript. It provides an API for efficient data storage and retrieval, supporting asynchronous operations. This makes it a user-friendly tool for developers looking to simplify database interactions.
GitHub Stars
0
User Rating
Not Rated
Favorites
0
Views
32
Forks
0
Issues
1
MCP LevelDB
A Model Context Protocol (MCP) tool for accessing and manipulating LevelDB databases from Claude Code.
Features
- Read LevelDB databases from any location on the filesystem
- Connect to remote LevelDB servers over HTTP
- Query specific keys or retrieve all entries with flexible filtering
- Retrieve database information like size, key count, and structure
- Support for traversing nested structures
- JSON-friendly results for Claude Code consumption
- Multiple authentication methods for remote servers (API Key, Basic Auth)
Installation
From NPM (Coming Soon)
npm install -g mcp-leveldb
From Source
git clone https://github.com/yourusername/mcp-leveldb.git
cd mcp-leveldb
npm install
npm run build
npm link # Optional: Make the CLI globally available
Usage with Claude Code
First, register the MCP with Claude Code:
claude mcp add leveldb -- mcp-leveldb server
Then, in Claude Code, you can use the MCP like this:
Local Database Access
// Get all entries from a local LevelDB database
const result = await fetch('http://localhost:3000/', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'leveldb-get-all',
parameters: {
dbPath: '/path/to/leveldb',
prefix: 'user:' // Optional prefix filter
}
})
});
const data = await result.json();
// Process data.entries
Remote Database Access
// Connect to a remote LevelDB server with API key authentication
const result = await fetch('http://localhost:3000/', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'leveldb-get-all',
parameters: {
connectionOptions: {
type: 'remote',
url: 'https://leveldb-server.example.com/api',
apiKey: 'your-api-key-here'
},
prefix: 'user:' // Optional prefix filter
}
})
});
const data = await result.json();
// Process data.entries
CLI Usage
The tool also provides a command-line interface for testing and debugging LevelDB databases:
# Start the MCP server
mcp-leveldb server -p 3000
# Test a local LevelDB database
mcp-leveldb test /path/to/leveldb --key specific-key
mcp-leveldb test /path/to/leveldb --prefix user:
# Test a remote LevelDB database
mcp-leveldb test --remote https://leveldb-server.example.com/api --api-key your-api-key --prefix user:
API Reference
Actions
leveldb-get
Get a specific key from a LevelDB database.
Parameters for local database:
dbPath(string): Path to the LevelDB database directorykey(string): The key to retrieve
Parameters for remote database:
connectionOptions(object): Connection options for the databasetype(string): Must be 'remote'url(string): URL of the remote LevelDB serverapiKey(string, optional): API key for authenticationusernameandpassword(string, optional): Basic auth credentials
key(string): The key to retrieve
Returns:
value: The value associated with the key
leveldb-get-all
Get all entries from a LevelDB database, optionally filtered by prefix.
Parameters for local database:
dbPath(string): Path to the LevelDB database directoryprefix(string, optional): Filter keys starting with this prefixlimit(number, optional): Maximum number of entries to returnskip(number, optional): Number of entries to skip
Parameters for remote database:
connectionOptions(object): Connection options for the databasetype(string): Must be 'remote'url(string): URL of the remote LevelDB serverapiKey(string, optional): API key for authenticationusernameandpassword(string, optional): Basic auth credentials
prefix(string, optional): Filter keys starting with this prefixlimit(number, optional): Maximum number of entries to returnskip(number, optional): Number of entries to skip
Returns:
entries: Array of key-value pairs
leveldb-keys
Get all keys from a LevelDB database, optionally filtered by prefix.
Parameters for local database:
dbPath(string): Path to the LevelDB database directoryprefix(string, optional): Filter keys starting with this prefixlimit(number, optional): Maximum number of keys to returnskip(number, optional): Number of keys to skip
Parameters for remote database:
connectionOptions(object): Connection options for the databasetype(string): Must be 'remote'url(string): URL of the remote LevelDB serverapiKey(string, optional): API key for authenticationusernameandpassword(string, optional): Basic auth credentials
prefix(string, optional): Filter keys starting with this prefixlimit(number, optional): Maximum number of keys to returnskip(number, optional): Number of keys to skip
Returns:
keys: Array of keys
leveldb-info
Get information about a LevelDB database.
Parameters for local database:
dbPath(string): Path to the LevelDB database directory
Parameters for remote database:
connectionOptions(object): Connection options for the databasetype(string): Must be 'remote'url(string): URL of the remote LevelDB serverapiKey(string, optional): API key for authenticationusernameandpassword(string, optional): Basic auth credentials
Returns:
size: Approximate size of the database in byteskeyCount: Approximate number of keysdataStructure: Sample of the data structure
Connection Options
The MCP supports two types of connections:
Local Connection
{
type: 'local',
path: '/path/to/leveldb',
// Optional LevelDB options
valueEncoding: 'utf8',
cacheSize: 8 * 1024 * 1024, // 8MB
readOnly: true
}
Remote Connection
{
type: 'remote',
url: 'https://leveldb-server.example.com/api',
// Authentication (choose one):
apiKey: 'your-api-key-here',
// Or:
username: 'user',
password: 'pass'
}
Error Handling
The MCP gracefully handles various error conditions:
- Non-existent database paths
- Invalid LevelDB databases
- Access permission issues
- Corrupted keys or values
- JSON parsing errors
- Remote server connection failures
- Authentication errors
Errors are returned with appropriate status and messages.
Contributors
- Your Name your.email@example.com
License
MIT