mcp-leveldb

mcp-leveldbは、TypeScriptで実装されたLevelDBのラッパーライブラリです。データの保存や取得を効率的に行うためのAPIを提供し、非同期処理にも対応しています。データベースの操作が簡単に行えるため、開発者にとって使いやすいツールです。

GitHubスター

0

ユーザー評価

未評価

お気に入り

0

閲覧数

19

フォーク

0

イシュー

1

README
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 directory
  • key (string): The key to retrieve

Parameters for remote database:

  • connectionOptions (object): Connection options for the database
    • type (string): Must be 'remote'
    • url (string): URL of the remote LevelDB server
    • apiKey (string, optional): API key for authentication
    • username and password (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 directory
  • prefix (string, optional): Filter keys starting with this prefix
  • limit (number, optional): Maximum number of entries to return
  • skip (number, optional): Number of entries to skip

Parameters for remote database:

  • connectionOptions (object): Connection options for the database
    • type (string): Must be 'remote'
    • url (string): URL of the remote LevelDB server
    • apiKey (string, optional): API key for authentication
    • username and password (string, optional): Basic auth credentials
  • prefix (string, optional): Filter keys starting with this prefix
  • limit (number, optional): Maximum number of entries to return
  • skip (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 directory
  • prefix (string, optional): Filter keys starting with this prefix
  • limit (number, optional): Maximum number of keys to return
  • skip (number, optional): Number of keys to skip

Parameters for remote database:

  • connectionOptions (object): Connection options for the database
    • type (string): Must be 'remote'
    • url (string): URL of the remote LevelDB server
    • apiKey (string, optional): API key for authentication
    • username and password (string, optional): Basic auth credentials
  • prefix (string, optional): Filter keys starting with this prefix
  • limit (number, optional): Maximum number of keys to return
  • skip (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 database
    • type (string): Must be 'remote'
    • url (string): URL of the remote LevelDB server
    • apiKey (string, optional): API key for authentication
    • username and password (string, optional): Basic auth credentials

Returns:

  • size: Approximate size of the database in bytes
  • keyCount: Approximate number of keys
  • dataStructure: 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
License

MIT