Integration

REST and MCP API

This guide shows how to drive knowmind from your own applications. Two interfaces are available: REST for classic back-end integrations and MCP (JSON-RPC 2.0 over HTTP) for AI tools.

Audience
Developers integrating knowmind into their own applications, workflows or back-end services. Requires basic HTTP, JSON and programming-language knowledge.

Prerequisites

  • knowmind account on Business API or Enterprise (for personal API tokens and 60+ requests per minute)
  • API token of the form kmt_… (see: Create an API token)
  • TLS-capable HTTP client in your language of choice
Note

Two interfaces, one token

REST and MCP use the same bearer token, the same endpoint host and the same tenant isolation. Choose REST for structured CRUD operations; choose MCP to integrate with language models (tool calls).
Architecture of the knowmind API. Your application speaks HTTPS to REST or MCP. The memory service holds BM25 and pgvector in PostgreSQL and the knowledge graph in Neo4j.

Steps

  1. 1

    Endpoint and authentication

    All requests go to https://knowmind.de. Authentication is via the Authorization: Bearer kmt_… header.

    text
    REST:  https://knowmind.de/api/v1/...
    MCP:   https://knowmind.de/api/mcp/v1
    Auth:  Authorization: Bearer kmt_…

    Outcome: curl -H "Authorization: Bearer kmt_…" https://knowmind.de/api/health returns a success message.

  2. 2

    REST example: search and store

    curl:

    bash
    # Search
    curl -X POST https://knowmind.de/api/v1/memory/recall \
      -H "Authorization: Bearer kmt_…" \
      -H "Content-Type: application/json" \
      -d '{
        "query": "Who is the onboarding contact?",
        "k": 5,
        "hops": 2,
        "use_graph": true
      }'
    
    # Create a memory
    curl -X POST https://knowmind.de/api/v1/memory/entries \
      -H "Authorization: Bearer kmt_…" \
      -H "Content-Type: application/json" \
      -d '{
        "memory_type": "semantic",
        "title": "QM training mandatory",
        "content": "All service staff complete the QM training annually.",
        "tags": ["qm", "training"],
        "source": "internal-handbook"
      }'

    TypeScript (Node 20+):

    ts
    const TOKEN = process.env.KNOWMIND_TOKEN!;
    const BASE = "https://knowmind.de/api/v1";
    
    async function recall(query: string, k = 5) {
      const r = await fetch(`${BASE}/memory/recall`, {
        method: "POST",
        headers: {
          Authorization: `Bearer ${TOKEN}`,
          "Content-Type": "application/json",
        },
        body: JSON.stringify({ query, k, hops: 2, use_graph: true }),
      });
      if (!r.ok) throw new Error(`recall failed: ${r.status}`);
      return r.json();
    }
    
    const hits = await recall("Who drafted the Müller contract?");
    console.log(hits);

    Python:

    python
    import os, requests
    
    TOKEN = os.environ["KNOWMIND_TOKEN"]
    BASE = "https://knowmind.de/api/v1"
    HEADERS = {"Authorization": f"Bearer {TOKEN}", "Content-Type": "application/json"}
    
    def recall(query: str, k: int = 5) -> dict:
        r = requests.post(
            f"{BASE}/memory/recall",
            headers=HEADERS,
            json={"query": query, "k": k, "hops": 2, "use_graph": True},
            timeout=10,
        )
        r.raise_for_status()
        return r.json()
    
    print(recall("GDPR training mandatory?"))
  3. 3

    MCP example: JSON-RPC 2.0

    MCP calls are JSON-RPC 2.0 requests against /api/mcp/v1. By default the response is a single JSON object. If you need Streamable HTTP (for native custom connectors), set Accept: text/event-stream.

    bash
    # List tools
    curl -X POST https://knowmind.de/api/mcp/v1 \
      -H "Authorization: Bearer kmt_…" \
      -H "Content-Type: application/json" \
      -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'
    
    # Call recall
    curl -X POST https://knowmind.de/api/mcp/v1 \
      -H "Authorization: Bearer kmt_…" \
      -H "Content-Type: application/json" \
      -d '{
        "jsonrpc": "2.0",
        "id": 2,
        "method": "tools/call",
        "params": {
          "name": "knowmind.recall",
          "arguments": { "query": "When is the next quarterly report due?", "k": 5 }
        }
      }'

    Outcome: The response is a JSON-RPC response object with result (success) or error (failure).

  4. 4

    Respect rate limits

    Business API plan: 60 requests per minute. Enterprise: 600. Excess returns HTTP 429 with a Retry-After header in seconds.

    Build a backoff mechanism in your client that reads Retry-After, waits the specified seconds (with jitter) and retries up to three times.

Verify the result

The integration is healthy when all three conditions hold:

  • GET /api/health with a valid bearer token returns HTTP 200 with service status.
  • A POST /api/v1/memory/recall with a known question returns at least one hit.
  • In the knowmind dashboard under API Tokens, the "last used" timestamp updates after a call.

Troubleshooting

Error messageCauseResolution
401 UnauthorizedMissing token, revoked token, or typo in the header.Check the token in the dashboard. Header format: Authorization: Bearer kmt_… with a space between Bearer and the token.
403 ForbiddenToken does not have the required scope (write is needed for creation).Edit the token scope in the dashboard or create a new token with read and write.
429 Too Many RequestsRate limit exceeded (60/min on Business API).Parse the Retry-After header, back off, and consider Enterprise for 600 req/min.
422 Unprocessable Entity on /memory/entriesRequired field missing or memory_type outside the enum.Required fields: memory_type, title, content. Valid types: semantic, episodic, procedural, reference, working, entity.
504 Gateway Timeout on long uploadsDocuments larger than 10,000 characters are processed as a background job.The response contains job_id. Poll GET /api/v1/jobs/{id} until status: ready.

Related