@tymio/mcp-server 1.0.0 → 2.0.0

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,30 @@
1
+ # Changelog
2
+
3
+ ## 2.0.0
4
+
5
+ ### Breaking
6
+
7
+ - **Pinned workspace for stdio** — `tymio-mcp` (OAuth proxy and API-key bridge) **requires** `TYMIO_WORKSPACE_SLUG` or `DRD_WORKSPACE_SLUG` (the hub workspace slug this process is bound to). Every tool call must include **`workspaceSlug`** matching that pin (case-insensitive). Prevents agents from targeting another workspace for the same user.
8
+ - **Tests / local tooling only** — set `TYMIO_MCP_SKIP_WORKSPACE_PINNING=1` to skip the startup requirement (do not use in production agent configs).
9
+
10
+ ### Added / changed
11
+
12
+ - **API-key stdio** — Resolves the pinned slug to a tenant via `GET /api/me/tenants` and sends **`X-Tenant-Id`** on all hub REST calls; tool payloads still carry `workspaceSlug` for consistency but must match the pin.
13
+ - **OAuth stdio (hub proxy)** — Asserts tool arguments match the pinned slug before `callTool` to the hosted MCP.
14
+ - **Hub (server) MCP** — Stricter `workspaceSlug` validation (length, `^[a-z0-9-]+$`) and **case-insensitive** match to the session workspace; API-key sessions can use tenant-list routes needed for resolution (`authViaApiKey` + `requireSession` behavior).
15
+
16
+ ### Requires
17
+
18
+ - **Deploy hub** with the matching server changes **before or with** rolling out this CLI to users who rely on API-key stdio or the updated MCP slug rules.
19
+
20
+ ## 1.1.0
21
+
22
+ - **Bundled agent personas** (`personas/*.md`): `workspace`, `pm`, `po`, `dev` — aligned with Tymio hub roles; shipped in the npm tarball.
23
+ - **`tymio-mcp persona list`** and **`tymio-mcp persona <id>`** — print persona Markdown to stdout (or list ids).
24
+ - **`TYMIO_MCP_PERSONA`** — optional env on the stdio process; appends the selected persona to MCP server **`instructions`** after the main agent guide (`hub` aliases `workspace`). Invalid values log a stderr warning and fall back to the base guide only.
25
+ - **Startup stderr hint** — when a valid persona is set, reminds that instructions include it and how to print the prompt (`tymio-mcp persona <id>`).
26
+ - **Agent guidance** — `TYMIO_MCP_CLI_AGENT_GUIDANCE.md` updated with persona usage; `README.md` and help text document commands and env.
27
+
28
+ ## 1.0.1
29
+
30
+ Prior release (OAuth proxy, API-key REST subset, `tymio-mcp instructions`, login/logout).
package/README.md CHANGED
@@ -1,84 +1,194 @@
1
- # Tymio MCP server (stdio)
1
+ # Tymio MCP CLI (`@tymio/mcp-server`)
2
2
 
3
- Local **stdio** MCP server for the Tymio hub: exposes REST APIs as [MCP](https://modelcontextprotocol.io/) tools using a **Bearer API key**. Use for scripts, CI, or when you do not want remote OAuth.
3
+ **Canonical Markdown for coding agents:** [`TYMIO_MCP_CLI_AGENT_GUIDANCE.md`](./TYMIO_MCP_CLI_AGENT_GUIDANCE.md) same text as `tymio-mcp instructions`, MCP server `instructions` (initialize), and `GET /api/mcp/agent-context` → `tymioMcpCliAgentGuidanceMarkdown` on the hub. It states explicitly that **there is no per-user MCP API key in Tymio Settings**; use OAuth (remote `/mcp` or `tymio-mcp login`).
4
4
 
5
- **Remote MCP** (recommended for daily Cursor use) runs inside the main Express app at `POST /mcp` with OAuth 2.1 and Google. See **[docs/HUB.md](../docs/HUB.md)** §6 for architecture, Google callback URL, and Cursor config (local + remote).
5
+ Installable **`tymio-mcp`** command: connect editors and agents to **Tymio** in two ways:
6
+
7
+ 1. **OAuth (default)** — stdio MCP server that **proxies** the hosted **Streamable HTTP** MCP endpoint (`…/mcp`) with the same **Google → Tymio** login as the web app. **Full tool surface** matches the hub (`server/src/mcp/tools.ts`).
8
+ 2. **API key (optional)** — if `DRD_API_KEY` or `API_KEY` is set, uses a **REST** bridge with a **fixed subset** of tools (see `mcp/src/apiKeyStdio.ts`).
6
9
 
7
10
  ---
8
11
 
9
- ## Prerequisites
12
+ ## Quick start (OAuth, production)
10
13
 
11
- 1. Server env: `API_KEY` set; optional `API_KEY_USER_ID` (otherwise first `SUPER_ADMIN` is used).
12
- 2. Tymio API running (e.g. `npm run dev` from repo root).
14
+ 1. Install the CLI (from npm when published, or `npm install -g /path/to/repo/mcp`).
15
+ 2. In a terminal:
13
16
 
14
- ## Environment
17
+ ```bash
18
+ tymio-mcp login
19
+ ```
15
20
 
16
- | Variable | Required | Description |
17
- |----------|----------|-------------|
18
- | `DRD_API_BASE_URL` | No (default `http://localhost:8080`) | Hub API base URL |
19
- | `DRD_API_KEY` | Yes for authenticated tools | Same value as server `API_KEY` |
21
+ A browser window opens; complete Google sign-in. Tokens and dynamic OAuth client data are stored under your user config directory (e.g. `~/.config/tymio-mcp` on Linux, or `~/Library/Application Support/tymio-mcp` on macOS).
20
22
 
21
- ## Install globally (npm)
23
+ 3. Point your MCP client at stdio **without** setting `DRD_API_KEY`:
22
24
 
23
- After the package is [published](https://docs.npmjs.com/creating-and-publishing-scoped-public-packages) to the `@tymio` scope (or from a local checkout):
25
+ ```json
26
+ {
27
+ "mcpServers": {
28
+ "tymio": {
29
+ "command": "tymio-mcp",
30
+ "args": []
31
+ }
32
+ }
33
+ }
34
+ ```
24
35
 
25
- ```bash
26
- npm install -g @tymio/mcp-server
27
- ```
36
+ 4. Optional: `tymio-mcp logout` removes saved OAuth files.
28
37
 
29
- This installs the **`tymio-mcp`** command on your `PATH`. Until it is on the registry, install from the repo:
38
+ **Agents / IDE:** MCP clients that support [server instructions](https://modelcontextprotocol.io) receive the same long-form guide as `tymio-mcp instructions` during the initialize handshake. You can still run `tymio-mcp instructions` in a terminal to print it, or read this README.
30
39
 
31
- ```bash
32
- npm install -g /absolute/path/to/proproman/mcp
33
- ```
40
+ ### Bundled agent personas (PM / PO / DEV)
34
41
 
35
- ## Build and run
42
+ The package ships Markdown prompts in **`personas/`** (aligned with Cursor Skills in the monorepo).
36
43
 
37
- ```bash
38
- npm run mcp:build
39
- npm run mcp:start
44
+ | Mechanism | What it does |
45
+ |-----------|----------------|
46
+ | **`tymio-mcp persona list`** | Lists persona ids and usage |
47
+ | **`tymio-mcp persona pm`** (or `po`, `dev`, `workspace`) | Prints that prompt to **stdout** (pipe into docs or paste into a chat) |
48
+ | **`TYMIO_MCP_PERSONA=pm`** on the `tymio-mcp` process | **Appends** the same Markdown to MCP server **`instructions`** after the main CLI guide — steers the model for clients that honor instructions (no Skills required). Use `hub` as an alias for `workspace`. |
49
+
50
+ Example Cursor stdio config with a Product Owner bias:
51
+
52
+ ```json
53
+ {
54
+ "mcpServers": {
55
+ "tymio-po": {
56
+ "command": "tymio-mcp",
57
+ "args": [],
58
+ "env": { "TYMIO_MCP_PERSONA": "po" }
59
+ }
60
+ }
61
+ }
40
62
  ```
41
63
 
42
- Or from `mcp/`: `npm run build` && `npm run start`. The process uses **stdio**; it is spawned by the MCP client, not run interactively.
64
+ ### OAuth callback port
43
65
 
44
- ## Cursor (stdio)
66
+ The CLI listens on **`http://127.0.0.1:19876/callback`** during `login` (override with `TYMIO_OAUTH_PORT`). That URI must be reachable from your browser and should stay stable so it matches the dynamically registered OAuth client.
45
67
 
46
- With a global install, point the client at the `tymio-mcp` binary:
68
+ ### Hub URL
69
+
70
+ | Variable | Default | Purpose |
71
+ |----------|---------|---------|
72
+ | `TYMIO_MCP_URL` | `https://tymio.app/mcp` | Hosted MCP endpoint for OAuth proxy + `login` |
73
+
74
+ ---
75
+
76
+ ## API-key mode (REST subset, CI / automation)
77
+
78
+ If **`DRD_API_KEY` or `API_KEY`** is present in the environment, `tymio-mcp` **does not** use OAuth; it exposes the REST-based tool subset only.
79
+
80
+ | Variable | Default | Purpose |
81
+ |----------|---------|---------|
82
+ | `DRD_API_BASE_URL` | `https://tymio.app` | Hub **origin** (no `/mcp`) |
83
+ | `DRD_API_KEY` / `API_KEY` | — | Bearer key (server `API_KEY`) |
84
+
85
+ Example:
47
86
 
48
87
  ```json
49
88
  {
50
89
  "mcpServers": {
51
- "tymio-local": {
90
+ "tymio-api-key": {
52
91
  "command": "tymio-mcp",
53
92
  "args": [],
54
93
  "env": {
55
- "DRD_API_BASE_URL": "http://localhost:8080",
56
- "DRD_API_KEY": "same-as-server-API_KEY"
94
+ "DRD_API_KEY": "your-key",
95
+ "DRD_API_BASE_URL": "https://tymio.app"
57
96
  }
58
97
  }
59
98
  }
60
99
  }
61
100
  ```
62
101
 
63
- Without a global install, use `node` and the built file:
102
+ ---
103
+
104
+ ## Commands
105
+
106
+ | Command | Description |
107
+ |---------|-------------|
108
+ | `tymio-mcp` | Run stdio MCP (OAuth proxy unless API key env is set) |
109
+ | `tymio-mcp login [url]` | OAuth sign-in; optional MCP URL overrides `TYMIO_MCP_URL` |
110
+ | `tymio-mcp logout` | Delete stored OAuth client + tokens |
111
+ | `tymio-mcp instructions` / `guide` | Print full agent Markdown (same as MCP `instructions` base) |
112
+ | `tymio-mcp persona list` | Bundled persona ids (`pm`, `po`, `dev`, `workspace`) |
113
+ | `tymio-mcp persona <id>` | Print one persona Markdown to stdout |
114
+ | `tymio-mcp help` | Usage |
115
+
116
+ ---
117
+
118
+ ## Install globally (npm)
119
+
120
+ `npm install -g @tymio/mcp-server` works only **after** the package is published. **E404** means it is not on the registry yet. Publish from `mcp/`:
121
+
122
+ ```bash
123
+ cd mcp && npm login && npm publish --access public
124
+ ```
125
+
126
+ Or install from a clone:
127
+
128
+ ```bash
129
+ npm install -g /absolute/path/to/proproman/mcp
130
+ ```
131
+
132
+ ---
133
+
134
+ ## Build and run (monorepo)
135
+
136
+ ```bash
137
+ npm run mcp:build
138
+ npm run mcp:start
139
+ ```
140
+
141
+ From **`mcp/`**, run unit tests (uses `vitest.config.ts` in this folder):
142
+
143
+ ```bash
144
+ npm test
145
+ ```
146
+
147
+ From the **repo root**, use:
148
+
149
+ ```bash
150
+ npx vitest run --config mcp/vitest.config.ts
151
+ ```
152
+
153
+ Stdio processes are meant to be **spawned** by the MCP host, not run interactively.
154
+
155
+ ---
156
+
157
+ ## Direct remote MCP in Cursor (no CLI)
158
+
159
+ Your editor can use the hosted endpoint directly:
64
160
 
65
161
  ```json
66
162
  {
67
163
  "mcpServers": {
68
- "tymio-local": {
69
- "command": "node",
70
- "args": ["/ABSOLUTE/PATH/TO/repo/mcp/dist/index.js"],
71
- "env": {
72
- "DRD_API_BASE_URL": "http://localhost:8080",
73
- "DRD_API_KEY": "same-as-server-API_KEY"
74
- }
164
+ "tymio": {
165
+ "url": "https://tymio.app/mcp"
75
166
  }
76
167
  }
77
168
  }
78
169
  ```
79
170
 
80
- ## Tools
171
+ Use the **CLI** when the host only supports **stdio**, or you want a single npm-installed binary that reuses disk-persisted OAuth.
172
+
173
+ ---
174
+
175
+ ## Publishing to npm (maintainers)
176
+
177
+ The repo includes a **manual** GitHub Actions workflow (no automatic runs on push):
178
+
179
+ - **File:** `.github/workflows/mcp-server-publish.yml`
180
+ - **How to run:** GitHub → **Actions** → **MCP server — build & publish** → **Run workflow**
181
+ - **Default:** `dry-run` — runs `npm ci`, tests, build, `npm pack`, and `npm publish --dry-run` for the `mcp` workspace
182
+ - **Real publish:** choose input `publish` and ensure the repository secret **`NPM_TOKEN`** is set (npm automation token with publish access to the **`@tymio`** scope)
183
+
184
+ Local dry-run before tagging a release:
185
+
186
+ ```bash
187
+ npm run test --workspace mcp && npm run build --workspace mcp && npm publish -w mcp --access public --dry-run
188
+ ```
189
+
190
+ ---
81
191
 
82
- **Ontology / playbook (Tymio):** `tymio_get_coding_agent_guide` (full [CODING_AGENT_TYMIO.md](../docs/CODING_AGENT_TYMIO.md) from server), `tymio_get_agent_brief`, `tymio_list_capabilities`, `tymio_get_capability` — see [docs/HUB.md](../docs/HUB.md) §6.1.
192
+ ## Architecture reference
83
193
 
84
- **Backlog / data (historical `drd_*` prefix):** health, meta, initiatives, features, requirements, domains, products, accounts, partners, demands, campaigns, timeline, assignments, stakeholders, etc. Full list: `server/src/mcp/tools.ts` and `mcp/src/index.ts` (stdio subset).
194
+ Hosted MCP, OAuth, and Google callback URLs: **[docs/HUB.md](../docs/HUB.md)** §6. Hub tool implementations: `server/src/mcp/tools.ts`. OAuth proxy implementation: `mcp/src/hubProxyStdio.ts`. REST subset: `mcp/src/apiKeyStdio.ts`.
@@ -0,0 +1,100 @@
1
+ # Tymio MCP and `@tymio/mcp-server` — guidance for autonomous agents
2
+
3
+ ## Critical — read before advising the user
4
+
5
+ 1. **There is no per-user MCP API key in Tymio Settings, Profile, Account, or Integrations.** Do **not** instruct users to open the web app settings to “copy an API key for MCP” or “get the MCP key from preferences.” That path does not exist and causes repeated confusion.
6
+ 2. **Normal connection = OAuth**, not a personal secret from the UI:
7
+ - **Remote MCP in the IDE:** add server URL `https://tymio.app/mcp` (or your deployment origin + `/mcp`). Complete sign-in in the browser when the client prompts. **No API key to paste.**
8
+ - **Stdio npm package (default):** install `@tymio/mcp-server`, run `tymio-mcp login` once in a terminal (browser OAuth). Configure the MCP client to run `tymio-mcp` **without** setting `DRD_API_KEY` or `API_KEY` on that process unless you intentionally want API-key mode.
9
+ 3. **`DRD_API_KEY` / `API_KEY` on the stdio process** means the **server deployment automation secret** (the same value as the hub’s configured `API_KEY` for `Authorization: Bearer …` on REST). It is **not** something each user generates in the Tymio UI. Only operators with access to deployment secrets use it (CI, scripts, optional stdio “REST bridge” mode).
10
+ 4. **Default vs API-key stdio:** If `DRD_API_KEY` or `API_KEY` is set to a non-empty value in the **environment of the `tymio-mcp` process**, the CLI uses a **fixed REST tool subset**, not OAuth to the hosted hub. For the **full** tool surface, use **remote** `…/mcp` or stdio **without** those env vars (after `tymio-mcp login`).
11
+ 5. **Full text of this guide:** shell command `tymio-mcp instructions` (or `tymio-mcp guide`). MCP clients that support server `instructions` receive this content at initialize when using the published CLI.
12
+ 6. **Bundled agent personas (PM / PO / DEV / workspace):** optional Markdown prompts ship with the package under `personas/`. **Print a prompt:** `tymio-mcp persona pm` (or `po`, `dev`, `workspace`). **Embed in MCP `instructions`:** set `TYMIO_MCP_PERSONA=pm` (same ids; `hub` aliases `workspace`) on the `tymio-mcp` process — the stdio server appends that persona after this guide so clients that honor `instructions` steer the model without Cursor Skills. **List ids:** `tymio-mcp persona list`.
13
+
14
+ ---
15
+
16
+ ## What `@tymio/mcp-server` is
17
+
18
+ - **Default (no API key env on the process):** A **stdio MCP server** that connects to the **hosted Tymio Streamable HTTP MCP** endpoint with **OAuth** (Google via the hub). It **proxies the full tool list** from the hub (same as using the remote URL in the IDE).
19
+ - **With `DRD_API_KEY` or `API_KEY` set:** A **REST/API-key** stdio server with a **smaller, fixed tool set** (good for CI/scripts).
20
+
21
+ ---
22
+
23
+ ## One-time setup (OAuth, stdio package)
24
+
25
+ 1. Install: `npm install -g @tymio/mcp-server` (or run a built `dist/index.js` via `node`).
26
+ 2. Run: `tymio-mcp login` — browser opens; complete Google sign-in for Tymio.
27
+ 3. Tokens and OAuth client metadata live under the user config directory (e.g. Linux: `~/.config/tymio-mcp`, macOS: `~/Library/Application Support/tymio-mcp`).
28
+ 4. **Callback:** default `http://127.0.0.1:19876/callback` during login — override with `TYMIO_OAUTH_PORT` if needed; keep stable for your registered OAuth client.
29
+
30
+ ---
31
+
32
+ ## Cursor / IDE (stdio, OAuth — recommended for this package)
33
+
34
+ Add an MCP server that runs the binary **without** `DRD_API_KEY` / `API_KEY`:
35
+
36
+ ```json
37
+ {
38
+ "mcpServers": {
39
+ "tymio": {
40
+ "command": "tymio-mcp",
41
+ "args": []
42
+ }
43
+ }
44
+ }
45
+ ```
46
+
47
+ If `tymio-mcp` is not on `PATH`, use `node` with an absolute path to `dist/index.js`.
48
+
49
+ ---
50
+
51
+ ## Alternative: remote MCP URL (no npm CLI)
52
+
53
+ If the host supports **URL** transport, point at the hub (OAuth handled by the IDE):
54
+
55
+ ```json
56
+ {
57
+ "mcpServers": {
58
+ "tymio": {
59
+ "url": "https://tymio.app/mcp"
60
+ }
61
+ }
62
+ }
63
+ ```
64
+
65
+ Replace the host when not using production.
66
+
67
+ ---
68
+
69
+ ## API-key mode (REST subset, intentional)
70
+
71
+ Set `DRD_API_KEY` (or `API_KEY`) and optionally `DRD_API_BASE_URL` (default `https://tymio.app`). Then `tymio-mcp` uses the REST bridge, **not** OAuth to the hosted MCP tool list.
72
+
73
+ ---
74
+
75
+ ## Environment reference
76
+
77
+ | Variable | Default | Purpose |
78
+ |----------|---------|---------|
79
+ | `TYMIO_MCP_URL` | `https://tymio.app/mcp` | Hosted MCP URL for OAuth proxy + `login` |
80
+ | `TYMIO_OAUTH_PORT` | `19876` | Loopback port for login callback |
81
+ | `TYMIO_MCP_QUIET` | unset | If set, suppress stderr hints when starting stdio |
82
+ | `DRD_API_KEY` / `API_KEY` | unset | If set → API-key REST bridge (subset), not OAuth proxy |
83
+ | `DRD_API_BASE_URL` | `https://tymio.app` | Hub origin for API-key bridge |
84
+
85
+ ---
86
+
87
+ ## Troubleshooting
88
+
89
+ - **401 / not signed in (stdio OAuth):** Run `tymio-mcp login` again.
90
+ - **User asks where to copy MCP API key:** Explain there is **no** such key in the UI; use **remote `/mcp` + OAuth** or **`tymio-mcp login`**.
91
+ - **Port in use on login:** Change `TYMIO_OAUTH_PORT` and re-run `login` (redirect URI must stay consistent).
92
+ - **Help:** `tymio-mcp help` — **full guide:** `tymio-mcp instructions`
93
+
94
+ ---
95
+
96
+ ## Machine-readable pointers
97
+
98
+ - **JSON (public):** `GET https://tymio.app/api/mcp/agent-context` — includes `tymioMcpCliAgentGuidanceMarkdown` (this file’s contents when the server can read it from disk).
99
+ - **Markdown site summary:** `https://tymio.app/llms.txt`
100
+ - **Repository:** `mcp/README.md`, `docs/HUB.md` §6, `docs/CODING_AGENT_HANDOFF_TYMIO_APP.md`
package/dist/api.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Minimal Tymio hub API client for the stdio MCP server. Uses DRD_API_BASE_URL and DRD_API_KEY from env.
3
3
  */
4
+ export declare function setApiKeyBridgeTenantId(tenantId: string): void;
5
+ export declare function clearApiKeyBridgeTenant(): void;
4
6
  /** JSON-friendly body; plain objects are stringified. */
5
7
  export type DrdFetchInit = Omit<RequestInit, "body"> & {
6
8
  body?: string | Record<string, unknown>;
package/dist/api.js CHANGED
@@ -1,10 +1,22 @@
1
1
  /**
2
2
  * Minimal Tymio hub API client for the stdio MCP server. Uses DRD_API_BASE_URL and DRD_API_KEY from env.
3
3
  */
4
- const baseUrl = process.env.DRD_API_BASE_URL ?? "http://localhost:8080";
4
+ /** Hub origin (no `/mcp` path). Stdio bridge calls REST under `/api/...`. */
5
+ const baseUrl = process.env.DRD_API_BASE_URL ?? "https://tymio.app";
5
6
  const apiKey = process.env.DRD_API_KEY ?? process.env.API_KEY ?? "";
7
+ /** Set by API-key stdio after resolving slug → tenant id (never send cross-tenant requests). */
8
+ let bridgeTenantHeaders = {};
9
+ export function setApiKeyBridgeTenantId(tenantId) {
10
+ bridgeTenantHeaders = { "X-Tenant-Id": tenantId };
11
+ }
12
+ export function clearApiKeyBridgeTenant() {
13
+ bridgeTenantHeaders = {};
14
+ }
6
15
  function headers() {
7
- const h = { "Content-Type": "application/json" };
16
+ const h = {
17
+ "Content-Type": "application/json",
18
+ ...bridgeTenantHeaders
19
+ };
8
20
  if (apiKey)
9
21
  h["Authorization"] = `Bearer ${apiKey}`;
10
22
  return h;
@@ -0,0 +1 @@
1
+ export declare function runApiKeyStdio(): Promise<void>;