@adaptiqai/mcp 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,18 @@
1
+ {
2
+ "name": "adaptiqai",
3
+ "version": "0.1.1",
4
+ "description": "AdaptiqAI's knowledge and memory tools in Claude Code: search, use and save your collections in the conversation you are in.",
5
+ "author": {
6
+ "name": "AdaptiqAI",
7
+ "url": "https://adaptiqai.com"
8
+ },
9
+ "homepage": "https://adaptiqai.com",
10
+ "license": "UNLICENSED",
11
+ "keywords": ["adaptiqai", "knowledge", "memory"],
12
+ "mcpServers": {
13
+ "adaptiqai": {
14
+ "command": "/bin/sh",
15
+ "args": ["${CLAUDE_PLUGIN_ROOT}/bin/adaptiqai-mcp"]
16
+ }
17
+ }
18
+ }
package/README.md CHANGED
@@ -1,3 +1,118 @@
1
- # Temporary Holding Version
1
+ # AdaptiqAI for Claude Code, Cline and any MCP app
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Your AdaptiqAI knowledge and this conversation's memory, as tools for the
4
+ agent: an MCP server, over stdio, on the AdaptiqAI core.
5
+
6
+ ## Install
7
+
8
+ **Claude Code**
9
+
10
+ ```bash
11
+ claude mcp add adaptiqai -- npx -y @adaptiqai/mcp
12
+ ```
13
+
14
+ or install it as a Claude Code plugin from a marketplace that lists it (the
15
+ package carries `.claude-plugin/plugin.json`). The plugin runs the server
16
+ from the package with a Node.js 22 or newer: Claude Code itself needs none,
17
+ and one started from the Dock often runs without a terminal's PATH, so
18
+ `bin/adaptiqai-mcp` looks in PATH, then where Volta, fnm, asdf, mise,
19
+ Homebrew and nvm put Node.js, or takes the one `ADAPTIQAI_NODE` names (in the
20
+ `env` of Claude Code's settings). With none, the AdaptiqAI tools are missing
21
+ and the agent is told why. The plugin starts it with `/bin/sh`, so on
22
+ Windows add the server with `claude mcp add` as above.
23
+
24
+ **Cline** (the CLI, 3.0.74)
25
+
26
+ ```bash
27
+ cline mcp add adaptiqai --yes -- npx -y @adaptiqai/mcp
28
+ ```
29
+
30
+ That writes `~/.cline/data/settings/cline_mcp_settings.json`:
31
+
32
+ ```json
33
+ { "mcpServers": { "adaptiqai": { "transport": { "type": "stdio", "command": "npx", "args": ["-y", "@adaptiqai/mcp"] } } } }
34
+ ```
35
+
36
+ **Any other MCP app**: run `npx -y @adaptiqai/mcp` as a stdio server.
37
+
38
+ ## Sign in
39
+
40
+ The server signs in with the first of these it finds. The app's own key
41
+ comes first: knowledge has to be in the workspace the app's model reads.
42
+
43
+ - **Nothing to do when the app runs on an AdaptiqAI key the server can
44
+ see.** Claude Code set up by the console (Connect to app's `adaptiq-claude`)
45
+ passes its environment on to the servers it starts, and the server uses the
46
+ key Claude Code runs on when `ANTHROPIC_BASE_URL` is AdaptiqAI's. Cline's
47
+ OpenRouter provider, pointed at AdaptiqAI, keeps its key in Cline's settings.
48
+ - **A key**: `ADAPTIQAI_API_KEY` in the server's environment.
49
+ - **In the browser**: `npx -y @adaptiqai/mcp login`, or simply ask the agent
50
+ for your knowledge: while the computer is signed out, the first tool call
51
+ opens the approval page and tells the agent the code.
52
+
53
+ One browser sign-in serves every app on this computer. It is kept in
54
+ `~/.config/adaptiq/mcp/` (under `XDG_CONFIG_HOME` when set), readable by you
55
+ alone.
56
+ `npx -y @adaptiqai/mcp status` says whether this computer is signed in, and
57
+ `logout` signs it out.
58
+
59
+ ## What it does
60
+
61
+ - **`adaptiq_knowledge`**: what this conversation uses; search your saved
62
+ knowledge; use or stop a collection here.
63
+ - **`adaptiq_memory`**: how full the memory is; your saved collections; opens
64
+ Knowledge in the browser to tidy up. It can't keep a conversation private,
65
+ as the DeepSeek Harness and Pi plugins can: Claude Code and Cline send their
66
+ model requests themselves, so AdaptiqAI saves what they send.
67
+ - **`adaptiq_create_knowledge`**: save material (text, files, links) as a
68
+ collection, only when you ask for it. The server checks the request
69
+ against your own messages in the conversation, as every AdaptiqAI plugin
70
+ does.
71
+
72
+ Otherwise the tools, their words and their answers are the ones the DeepSeek
73
+ Harness and Pi plugins have (`agentTools` in `@adaptiqai/core`).
74
+
75
+ ## Which conversation a call is in
76
+
77
+ MCP has no conversation id, so the server reads each app where it keeps its
78
+ own:
79
+
80
+ | | Claude Code 2.1.308 | Cline 3.0.74 |
81
+ |---|---|---|
82
+ | What the app hands the server | `CLAUDE_CODE_SESSION_ID`, `CLAUDE_PROJECT_DIR` and its own environment; `_meta["claudecode/toolUseId"]` on every call | nothing (no id in the environment or `_meta`) |
83
+ | What its model requests name | `x-claude-code-session-id`, the same id | body `session_id`, only on its OpenRouter provider |
84
+ | How the server finds the call's conversation | the transcript (`~/.claude/projects/…/<id>.jsonl`) that holds the call's tool-use id: Claude Code keeps the server across `/clear` and `/resume`, so the starting id goes stale. An agent's call is in the agent's own transcript (`<id>/subagents/…/agent-<agent>.jsonl`), and is the session `<id>.<agent>`, as the gateway names an agent's requests; what an agent saves stays the chat's | the conversation whose messages file (`~/.cline/data/sessions/<id>/<id>.messages.json`) holds the call, not answered yet: Cline writes it there a few milliseconds before it makes it. Cline's hub runs every task in one process, so when two tasks make the same call at once, or no file holds it, the record started last before this server wins: Cline starts a server for each conversation |
85
+ | What has to be true for it to reach the model | Claude Code on the AdaptiqAI gateway with `CLAUDE_CODE_GATEWAY_HINT_HEADERS=1` (the gateway names a chat only from `x-claude-code-request-class: main`) | Cline's OpenRouter provider with its base URL set to the AdaptiqAI gateway |
86
+
87
+ When that is not so, every tool says why instead of attaching knowledge to a
88
+ conversation the model never reads. An app other than these two names no
89
+ conversation, so its tool calls are refused the same way.
90
+
91
+ The transcript also holds your own messages, which `adaptiq_create_knowledge`
92
+ checks its quote against. The server reads them on this computer, only when
93
+ the agent saves knowledge, as far back as your last messages go, and keeps
94
+ nothing of them.
95
+
96
+ ## Configuration
97
+
98
+ | Variable | Default |
99
+ |---|---|
100
+ | `ADAPTIQAI_API_KEY` | none. Used when the app runs on no AdaptiqAI key the server can see; else the browser sign-in |
101
+ | `ADAPTIQAI_API_BASE` | `https://api.adaptiqai.com` |
102
+ | `ADAPTIQAI_CONSOLE_URL` | `https://memory.adaptiqai.com/memory` |
103
+ | `ADAPTIQAI_NODE` | the plugin looks for a Node.js 22 or newer |
104
+
105
+ ## Development
106
+
107
+ ```bash
108
+ pnpm install
109
+ pnpm --filter @adaptiqai/mcp run build # lib/index.js, one file with core bundled in
110
+ pnpm --filter @adaptiqai/mcp run test
111
+ claude mcp add adaptiqai-dev -- node "$PWD/packages/mcp/lib/index.js"
112
+ ```
113
+
114
+ MCP over stdio is a few JSON-RPC methods (`initialize`, `ping`,
115
+ `tools/list`, `tools/call`), written by hand in `src/rpc.ts` and
116
+ `src/index.ts`: the server ships as one file with no dependencies. Claude
117
+ Code 2.1.308 asks for `server/discover` (MCP 2026-07-28) first and falls back
118
+ to `initialize` when the server does not know it, as this one does not.
@@ -0,0 +1,47 @@
1
+ #!/bin/sh
2
+ # The AdaptiqAI MCP server as the Claude Code plugin starts it, through
3
+ # /bin/sh, so a package that lost its file modes still starts (npx runs
4
+ # lib/index.js itself). Claude Code needs no Node.js of its own, and one
5
+ # started from the Dock or a menu often runs without the PATH a terminal gets
6
+ # from nvm, fnm, Volta, asdf, mise or Homebrew, so a Node.js 22 or newer is
7
+ # looked for there too, or ADAPTIQAI_NODE names one. With none, the server
8
+ # still answers, with no tools and instructions that say why: the agent can
9
+ # tell the person, where a server that fails to start says nothing.
10
+ root=$(cd "$(dirname "$0")/.." && pwd)
11
+
12
+ usable() {
13
+ [ -n "$1" ] && [ -x "$1" ] && "$1" -e 'process.exit(+process.versions.node.split(".")[0] >= 22 ? 0 : 1)' >/dev/null 2>&1
14
+ }
15
+
16
+ if [ -n "${ADAPTIQAI_NODE:-}" ]; then
17
+ usable "$ADAPTIQAI_NODE" && exec "$ADAPTIQAI_NODE" "$root/lib/index.js" "$@"
18
+ else
19
+ for node in "$(command -v node 2>/dev/null)" \
20
+ "${VOLTA_HOME:-$HOME/.volta}/bin/node" \
21
+ "${FNM_DIR:-$HOME/.local/share/fnm}/aliases/default/bin/node" \
22
+ "$HOME/Library/Application Support/fnm/aliases/default/bin/node" \
23
+ "$HOME/.asdf/shims/node" "$HOME/.local/share/mise/shims/node" \
24
+ /opt/homebrew/bin/node /usr/local/bin/node /usr/bin/node \
25
+ "${NVM_DIR:-$HOME/.nvm}"/versions/node/*/bin/node; do
26
+ usable "$node" && exec "$node" "$root/lib/index.js" "$@"
27
+ done
28
+ fi
29
+
30
+ reason='AdaptiqAI knowledge and memory are not available here: their MCP server needs Node.js 22 or newer on this computer, and the Claude Code plugin found none. When the person asks for AdaptiqAI knowledge or memory, tell them to install Node.js 22 or newer (nodejs.org), or to set ADAPTIQAI_NODE to one in the env of Claude Code'"'"'s settings, and then to start Claude Code again.'
31
+ echo "adaptiqai-mcp: $reason" >&2
32
+ while IFS= read -r line || [ -n "$line" ]; do
33
+ id=$(printf '%s\n' "$line" | sed -nE 's/.*"id":("[^"]*"|-?[0-9]+).*/\1/p')
34
+ # A notification has no id and gets no answer.
35
+ [ -n "$id" ] || continue
36
+ case $line in
37
+ *'"method":"initialize"'*)
38
+ version=$(printf '%s\n' "$line" | sed -nE 's/.*"protocolVersion":"([^"]*)".*/\1/p')
39
+ result="{\"protocolVersion\":\"${version:-2025-06-18}\",\"capabilities\":{\"tools\":{}},\"serverInfo\":{\"name\":\"adaptiqai\",\"title\":\"AdaptiqAI\",\"version\":\"0.0.0\"},\"instructions\":\"$reason\"}" ;;
40
+ *'"method":"tools/list"'*) result='{"tools":[]}' ;;
41
+ *'"method":"ping"'*) result='{}' ;;
42
+ *)
43
+ printf '{"jsonrpc":"2.0","id":%s,"error":{"code":-32601,"message":"Method not found"}}\n' "$id"
44
+ continue ;;
45
+ esac
46
+ printf '{"jsonrpc":"2.0","id":%s,"result":%s}\n' "$id" "$result"
47
+ done