Skip to content

klever-io/mcp-klever-connect

Repository files navigation

klever-connect-mcp

MCP server for klever-connect — Unified JavaScript/TypeScript SDK for the Klever blockchain. Provides offline transaction building, wallet management (Node + Browser extension), provider/network communication, smart contract interactions (ABI-based), HD wallets, and React hooks.

What's Inside

Knowledge File Entries Content
api-reference.json 46 API methods, classes, and interfaces
best-practices.json 11 Recommended patterns and security tips
configuration.json 5 Network, provider, and environment setup
documentation.json 9 Architecture guides and migration docs
errors.json 12 Common error patterns with fixes
examples.json 21 Working code snippets (Node.js, React, contracts)
patterns.json 12 Design patterns and integration workflows
types.json 9 TypeScript types and interfaces
Total 125

Quick Start

Run from npm (no clone, no build)

MODE=mcp npx -y @klever/klever-connect-mcp        # stdio mode (Claude Desktop / Cursor / Claude Code)
npx -y @klever/klever-connect-mcp                 # HTTP mode -> http://localhost:3000/mcp
MODE=public npx -y @klever/klever-connect-mcp     # public HTTP mode with security headers

Run from source

pnpm install
pnpm dev              # HTTP mode -> http://localhost:3000/mcp
MODE=mcp pnpm dev:mcp # stdio mode for Claude Desktop / Cursor

Requirements

  • Node.js >= 18.14.0
  • pnpm (recommended) or npm

Installation

git clone https://github.com/klever-io/mcp-klever-connect.git
cd mcp-klever-connect
pnpm install
pnpm build

Running

Streamable HTTP (default)

pnpm dev          # development (auto-reload)
pnpm start        # production (requires pnpm build first)

MCP endpoint: http://localhost:3000/mcp

stdio (Claude Desktop, Cursor, Claude Code)

MODE=mcp pnpm dev:mcp

Public mode (security headers + restricted CORS)

MODE=public CORS_ORIGINS=https://yourdomain.com pnpm dev:public

Configuration

Variable Default Description
MODE http http, public, mcp/stdio
PORT 3000 Server port
HOST 0.0.0.0 Bind address
KNOWLEDGE_DIR ./knowledge Path to knowledge JSONs
MAX_SIZE 10000 Max entries in memory
CORS_ORIGINS * Comma-separated allowed origins

MCP Tools

Tool Description
query_context Structured search with BM25 ranking + type/tag/category filters
get_context Retrieve full entry by ID
find_similar Find related entries by tag/type overlap
get_knowledge_stats Knowledge base overview (total, types, top tags)
enhance_with_context Augment a query with top-5 relevant entries
search_documentation Natural-language search with formatted markdown output

MCP Resources

URI Description
knowledge://index Browse all categories, types, and top tags
knowledge://category/{category} All entries in a category
knowledge://type/{type} All entries of a type
knowledge://entry/{id} Single entry with full content

Entry Types

Type Description
code_example Working code snippets
best_practice Recommended patterns
security_tip Security guidance
optimization Performance advice
documentation API reference and guides
error_pattern Common mistakes + fixes
deployment_tool Build/deploy instructions
runtime_behavior Lifecycle and gotchas

Search Quality

The knowledge base uses BM25 full-text ranking with:

  • Stopword filtering — removes noise words (the, is, how, what, show, code, example, etc.)
  • Stemming — matches plural/tense variations (balance/balances/balanced)
  • Weighted fields — titles and tags are weighted higher than content body
  • Relevance scoring — combines BM25 scores with curated relevance metadata

Project Structure

mcp-klever-connect/
├── src/
│   ├── types/index.ts          Zod schemas + TypeScript types
│   ├── storage/memory.ts       In-memory storage with BM25 search
│   ├── storage/index.ts        Storage exports
│   ├── context/service.ts      Business logic + relevance scoring
│   ├── utils/auto-ingest.ts    Knowledge JSON loader
│   ├── mcp/server.ts           MCP server (tools + resources + prompt hook)
│   ├── mcp/resources.ts        Resource builders (markdown output)
│   └── index.ts                Entry point (http/public/stdio modes)
├── knowledge/                  Knowledge base JSON files (125 entries)
├── package.json
├── tsconfig.json
├── Makefile
└── Dockerfile

Connecting MCP Clients

Claude Desktop (stdio)

Edit ~/Library/Application Support/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "klever-connect": {
      "command": "npx",
      "args": ["-y", "@klever/klever-connect-mcp"],
      "env": { "MODE": "mcp" }
    }
  }
}

Alternatively, point at a local build:

{
  "mcpServers": {
    "klever-connect": {
      "command": "node",
      "args": ["/absolute/path/to/mcp-klever-connect/dist/index.js"],
      "env": { "MODE": "mcp" }
    }
  }
}

Cursor (stdio)

Edit .cursor/mcp.json in your workspace:

{
  "mcpServers": {
    "klever-connect": {
      "command": "npx",
      "args": ["-y", "@klever/klever-connect-mcp"],
      "env": { "MODE": "mcp" }
    }
  }
}

Claude Code (stdio via npx)

claude mcp add klever-connect --env MODE=mcp -- npx -y @klever/klever-connect-mcp

Claude Code (Streamable HTTP)

claude mcp add klever-connect --transport http http://localhost:3000/mcp

Docker

docker build -t klever-connect-mcp .
docker run -p 3000:3000 -e MODE=public klever-connect-mcp   # HTTP public
docker run klever-connect-mcp                                 # stdio (default)

License

MIT

About

An MCP (Model Context Protocol) server that exposes the Klever Connect SDK knowledge base. API reference, types, examples, patterns, errors, best practices and documentation. To any MCP-compatible client

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors