Skip to main content
Glama
gaurav-oberoi

mcp-knowledge-base

README.md
# mcp-knowledge-base

A [Model Context Protocol](https://modelcontextprotocol.io) (MCP) server that exposes a notes
knowledge base to MCP clients — Claude Desktop, IDEs, or any agent. It demonstrates the two things an
MCP server provides: **tools** (actions the model can call) and **resources** (data the model can
read). TypeScript, runs over stdio.

![mcp](https://img.shields.io/badge/MCP-server-1c3c3c) ![typescript](https://img.shields.io/badge/TypeScript-node-3178c6)

## What it exposes

**Tools** ([`src/server.ts`](src/server.ts)):
| Tool | Purpose |
|------|---------|
| `search_notes` | keyword search across the knowledge base (title/tags/content weighted) |
| `add_note` | add a new note |
| `get_note` | fetch one note by id |

**Resources:** every note is readable at `note://{id}`, with a listing — so a client can browse the
knowledge base as data, not just call tools.

The domain logic (the notes store + search ranking) lives in [`src/notes.ts`](src/notes.ts), separate
from the protocol layer.

## Use it with an MCP client

Build it, then point a client at the binary. For example, in Claude Desktop's `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "knowledge-base": { "command": "node", "args": ["/abs/path/to/dist/index.js"] }
  }
}
```

```bash
npm install && npm run build
node dist/index.js     # speaks MCP over stdio
```

## Tests

```bash
npm test
```

Two layers, both offline:
- **Unit** — the notes store and search ranking.
- **Integration** — a real MCP `Client` talks to the server over an in-memory transport (the same
  way a client would over stdio): it lists tools, calls `search_notes`/`add_note`/`get_note`, and
  reads a `note://` resource. 9 tests total.

## License

MIT