MIDAAS

Developers

Four ways in: MCP, SDKs, webhooks, and the API.

Connect an assistant, call MIDAAS from your own code, or have it tell your systems when something happens.

  • MCP server. Five tools: ask, search, list_libraries, get_document and get_page. Connect with a personal API key sent as a header. There is no OAuth sign-in yet. The assistant sees exactly what that person can see.
  • Python and TypeScript SDKs. midaas for Python and @midaas/sdk for TypeScript: ask, streamed answers, upload and wait, libraries and collections, evaluation runs, webhook verification and typed errors. Included for customers.
  • Webhooks. document.completed, document.failed, document.deleted, pipeline.run.completed and eval.run.completed. Signed with HMAC-SHA256 in the MIDAAS-Signature header, retried six times over about nine hours, with a delivery log. No document text in payloads.
  • REST API and command line. Answers streamed over HTTP, and midas-ctl for adding documents, asking, and running your own question set against your own documents.
# connect Claude Code to your workspace over MCP
claude mcp add --transport http midaas \
  https://acme.midaas.app/api/v1/mcp \
  --header "Authorization: Bearer $MIDAAS_API_KEY"

# add a document to a collection
midas-ctl ingest file ./service-manual.pdf --collection indoor-units

# ask, with citations
midas-ctl query run "What plugs into DN66?"

# the same from Python, with the SDK
from midaas import Midaas
client = Midaas()  # reads MIDAAS_URL and MIDAAS_API_KEY
answer = client.ask("What plugs into DN66?", collection="indoor-units")
print(answer.text)

# or over HTTP, streamed as it's written
curl -N https://acme.midaas.app/api/v1/query \
  -H "X-API-Key: $MIDAAS_API_KEY" -H "Content-Type: application/json" \
  -d '{"query":"What plugs into DN66?","stream":true}'

# measure answer quality on your own questions
midas-ctl eval run --collection indoor-units

Example apps

A working chat, three ways.

Every workspace has these under Developers: a chat you can use straight away, and the code behind it to copy. Each one keeps the conversation going and lists the sources under every answer.

Ask from an assistant

Connect Claude, or any assistant that supports the Model Context Protocol, to your workspace. The assistant sees what you can see in MIDAAS and nothing more. It chooses among five tools itself: ask, search, list_libraries, get_document and get_page.

The chat in the app talks to the same endpoint an assistant does: one initialize, then a tools/call for each message.

The MCP tab in a MIDAAS workspace: the five tools an assistant can use, and a chat that talks to the MCP endpoint
The MCP tab in a workspace
Connect Claude Codeshell
claude mcp add --transport http midaas \
  https://your-workspace.midaas.app/api/v1/mcp \
  --header "Authorization: Bearer $MIDAAS_API_KEY"
mcp_chat.pypython
"""A minimal MCP client for MIDAAS, using only the Python standard library.

    export MIDAAS_API_KEY="<your key>"
    python mcp_chat.py
"""
import json
import os
import re
import urllib.error
import urllib.request

MCP_URL = "https://your-workspace.midaas.app/api/v1/mcp"
API_KEY = os.environ["MIDAAS_API_KEY"]

next_id = 0
protocol_version = None  # agreed at initialize, then sent with every request


def rpc(method, params=None, notification=False):
    """Send one JSON-RPC 2.0 message. Returns the result, or None for a notification."""
    global next_id
    message = {"jsonrpc": "2.0", "method": method}
    if params is not None:
        message["params"] = params
    if not notification:  # a notification has no id and gets no answer
        next_id += 1
        message["id"] = next_id
    headers = {
        "Authorization": f"Bearer {API_KEY}",
        "Content-Type": "application/json",
        "Accept": "application/json, text/event-stream",
    }
    if protocol_version:
        headers["MCP-Protocol-Version"] = protocol_version
    request = urllib.request.Request(MCP_URL, data=json.dumps(message).encode(), headers=headers, method="POST")
    try:
        with urllib.request.urlopen(request, timeout=120) as response:
            body = response.read()
    except urllib.error.HTTPError as exc:
        raise SystemExit(f"MIDAAS answered {exc.code}: {exc.read().decode(errors='replace')}")
    if notification or not body:
        return None
    reply = json.loads(body)
    if "error" in reply:
        raise RuntimeError(reply["error"]["message"])
    return reply["result"]


def text_of(result):
    """A tool result is a list of content parts; MIDAAS sends one text part."""
    return "\n".join(part["text"] for part in result["content"] if part["type"] == "text")


def main():
    global protocol_version
    hello = rpc("initialize", {
        "protocolVersion": "2025-06-18",
        "capabilities": {},
        "clientInfo": {"name": "mcp-chat", "version": "1.0.0"},
    })
    protocol_version = hello["protocolVersion"]
    rpc("notifications/initialized", notification=True)

    tools = rpc("tools/list")["tools"]
    print(f"Connected to {hello['serverInfo']['name']} {hello['serverInfo']['version']}.")
    print("Tools:", ", ".join(tool["name"] for tool in tools))
    print("Ask about your documents. Press Ctrl+C to stop.")

    conversation_id = None
    while True:
        try:
            question = input("\nYou: ").strip()
        except (EOFError, KeyboardInterrupt):
            print()
            break
        if not question:
            continue
        arguments = {"question": question}
        if conversation_id:
            arguments["conversation_id"] = conversation_id  # a follow-up in the same conversation
        result = rpc("tools/call", {"name": "ask", "arguments": arguments})
        text = text_of(result)
        if result.get("isError"):
            # One plain sentence: for example, the workspace's daily AI limit was reached.
            print("\nMIDAAS could not answer:", text)
            continue
        # The answer, then its Sources list, then the conversation_id to send next time.
        print("\nMIDAAS:", text)
        found = re.search(r"conversation_id: (\S+)", text)
        if found:
            conversation_id = found.group(1)


if __name__ == "__main__":
    main()
mcp-chat.tstypescript
// A minimal MCP client for MIDAAS, using only fetch (Node 18 or newer).
//
//   export MIDAAS_API_KEY="<your key>"
//   npx tsx mcp-chat.ts
import { createInterface } from "node:readline/promises";

const MCP_URL = "https://your-workspace.midaas.app/api/v1/mcp";
const API_KEY = process.env.MIDAAS_API_KEY;
if (!API_KEY) throw new Error("Set MIDAAS_API_KEY to one of your MIDAAS API keys.");

let nextId = 0;
let protocolVersion: string | undefined; // agreed at initialize, then sent with every request

/** Send one JSON-RPC 2.0 message. Resolves to the result, or undefined for a notification. */
async function rpc(method: string, params?: unknown, notification = false): Promise<any> {
  const message: Record<string, unknown> = { jsonrpc: "2.0", method };
  if (params !== undefined) message.params = params;
  if (!notification) message.id = ++nextId; // a notification has no id and gets no answer
  const headers: Record<string, string> = {
    Authorization: `Bearer ${API_KEY}`,
    "Content-Type": "application/json",
    Accept: "application/json, text/event-stream",
  };
  if (protocolVersion) headers["MCP-Protocol-Version"] = protocolVersion;

  const response = await fetch(MCP_URL, { method: "POST", headers, body: JSON.stringify(message) });
  const body = await response.text();
  if (!response.ok) throw new Error(`MIDAAS answered ${response.status}: ${body}`);
  if (notification || !body) return undefined;
  const reply = JSON.parse(body);
  if (reply.error) throw new Error(reply.error.message);
  return reply.result;
}

/** A tool result is a list of content parts; MIDAAS sends one text part. */
function textOf(result: { content: Array<{ type: string; text?: string }> }): string {
  return result.content.filter((part) => part.type === "text").map((part) => part.text ?? "").join("\n");
}

async function main(): Promise<void> {
  const hello = await rpc("initialize", {
    protocolVersion: "2025-06-18",
    capabilities: {},
    clientInfo: { name: "mcp-chat", version: "1.0.0" },
  });
  protocolVersion = hello.protocolVersion;
  await rpc("notifications/initialized", undefined, true);

  const { tools } = await rpc("tools/list");
  console.log(`Connected to ${hello.serverInfo.name} ${hello.serverInfo.version}.`);
  console.log("Tools:", tools.map((tool: { name: string }) => tool.name).join(", "));
  console.log("Ask about your documents. Press Ctrl+C to stop.");

  const terminal = createInterface({ input: process.stdin, output: process.stdout });
  let conversationId: string | undefined;
  for (;;) {
    let question: string;
    try {
      question = (await terminal.question("\nYou: ")).trim();
    } catch {
      break; // Ctrl+C or the end of the input
    }
    if (!question) continue;
    const args: Record<string, string> = { question };
    if (conversationId) args.conversation_id = conversationId; // a follow-up in the same conversation
    const result = await rpc("tools/call", { name: "ask", arguments: args });
    const text = textOf(result);
    if (result.isError) {
      // One plain sentence: for example, the workspace's daily AI limit was reached.
      console.log("\nMIDAAS could not answer:", text);
      continue;
    }
    // The answer, then its Sources list, then the conversation_id to send next time.
    console.log("\nMIDAAS:", text);
    conversationId = /conversation_id: (\S+)/.exec(text)?.[1] ?? conversationId;
  }
  terminal.close();
}

main().catch((error) => {
  console.error(error instanceof Error ? error.message : error);
  process.exit(1);
});

See it on your documents

Bring a manual you know well. Ask it the hard questions.

In a 30-minute walkthrough we load a few of your documents and you ask what your team actually asks. You'll see the answers, the citations and the pages they came from.