# Knowledge Fabric MCP server

> Enables AI clients to perform hybrid RAG and evidence retrieval using PostgreSQL with pgvector and multi-tenant security.

- Repository: https://github.com/invarcore/knowledge-fabric
- Page: https://hostedmcp.org/servers/invarcore/knowledge-fabric
- Transport: stdio
- Stars: 8
- License: Apache-2.0
- Latest version: 0.1.3

## Install

### Claude Code

```sh
claude mcp add knowledge-fabric -- uvx knowledge-fabric
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "knowledge-fabric": {
      "command": "uvx",
      "args": [
        "knowledge-fabric"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "knowledge-fabric": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "knowledge-fabric"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"knowledge-fabric","type":"stdio","command":"uvx","args":["knowledge-fabric"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "knowledge-fabric": {
      "command": "uvx",
      "args": [
        "knowledge-fabric"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add knowledge-fabric -- uvx knowledge-fabric
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.knowledge-fabric]
command = "uvx"
args = ["knowledge-fabric"]
```

### Gemini CLI

```sh
gemini mcp add -s user knowledge-fabric uvx -- knowledge-fabric
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "knowledge-fabric": {
      "command": "uvx",
      "args": [
        "knowledge-fabric"
      ]
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `DATABASE_URL` | no | no |  |
| `EMBEDDING_PROVIDER` | no | no |  |
| `KF_DEFAULT_TENANT` | no | no |  |
| `QDRANT_URL` | no | no |  |
| `RETRIEVAL_STORE_BACKEND` | no | no |  |

## Tools (8)

- `health_check`: Check server health and return runtime configuration. Returns embedding provider name and dimension, DB connectivity status, and approximate document/chunk counts. Useful for AI agents to orient themselves before querying.
- `list_sources`: List ingested source types and document counts for a tenant. Returns distinct source_type values with document counts so an AI agent can discover what content domains are available before issuing a query. Use source_type as a filter in retrieve_evidence to scope retrieval. Scoped to tenant_id when provided.
- `retrieve_evidence`: Execute evidence retrieval across indexed content. Parameters: - query_text: The natural-language or keyword search query. - top_k: Maximum number of ranked evidence chunks to return (default: 10). - source_type: Optional filter by source kind (e.g., 'markdown', 'confluence'). - trace_id: Optional client-supplied correlation ID for audit tracing. - tenant_id: Tenant namespace identifier (scopes search to tenant data; defaults to configured default tenant). - mode: Retrieval strategy: 'hybrid' (lexical + vector RRF), 'lexical' (full-text only), or 'vector' (semantic embeddings only). - format: Output presentation format: 'json' (standard payload), 'compact' (deduplicated token-efficient JSON), or 'markdown' (ready-to-cite markdown text). Default is 'json'.
- `get_document`
- `explain_retrieval`: Return diagnostic tracing and candidate scoring explanations for a query. Explains candidate counts, per-leg latencies, fusion scores, and degradation status without persisting audit logs.
- `get_index_status`: Return diagnostic index breakdown: document/chunk counts, sources, and storage status. Scoped to tenant_id when provided.
- `get_evidence`: Fetch a specific evidence chunk by its integer chunk ID, scoped to tenant.
- `check_consistency`: Run database consistency audits (detecting orphaned chunks, empty documents, null tenants).

## FAQ

### Does this require a separate vector database?

No, it runs directly on your existing PostgreSQL database using pgvector and native full-text search, eliminating the need for dedicated vector DB infrastructure.
