spaces-mcp

v0.1.2
@xyne/spaces-mcp Checked 3 days ago Published 1 month ago

MCP server for Xyne Spaces: channels, threads, messages, tickets, and search for coding agents

An MCP server that lets a coding agent read and write Xyne Spaces — channels, threads, messages, tickets, calls, canvases and search — through @xyne/spaces-sdk. 36 tools over the Spaces public API. Not 483: the SDK exposes every operation the product itself performs, and this exposes the ones an agent actually reaches for, each with an exact schema. You need Node 22 or later, and the address you open Xyne Spaces at — written below as https://. The Developers tab in Spaces shows these commands with your address already filled in.

Summary extracted from the README.

@xyne/spaces-mcp

An MCP server that lets a coding agent read and write Xyne Spaces — channels, threads, messages, tickets, calls, canvases and search — through @xyne/spaces-sdk.

36 tools over the Spaces public API. Not 483: the SDK exposes every operation the product itself performs, and this exposes the ones an agent actually reaches for, each with an exact schema.


Quick start

You need Node 22 or later, and the address you open Xyne Spaces at — written below as https://<your-spaces-host>. The Developers tab in Spaces shows these commands with your address already filled in.

1. Register the server. Every client launches it with npx, so there is nothing to install or update by hand.

claude mcp add xyne-spaces --scope user \
  -e XYNE_SPACES_BASE_URL=https://<your-spaces-host> \
  -- npx -y @xyne/spaces-mcp

--scope user makes it available in every project. Drop it to add it to the current project only.

The same entry, in whichever file that client reads — claude_desktop_config.json (Settings → Developer → Edit Config) for Claude Desktop, ~/.cursor/mcp.json for Cursor, ~/.codeium/windsurf/mcp_config.json for Windsurf:

{
  "mcpServers": {
    "xyne-spaces": {
      "command": "npx",
      "args": ["-y", "@xyne/spaces-mcp"],
      "env": { "XYNE_SPACES_BASE_URL": "https://<your-spaces-host>" }
    }
  }
}

Restart the client after editing the file.

In .vscode/mcp.json, or the user-level mcp.json:

{
  "servers": {
    "xyne-spaces": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@xyne/spaces-mcp"],
      "env": { "XYNE_SPACES_BASE_URL": "https://<your-spaces-host>" }
    }
  }
}

Any MCP client library can spawn it directly — there is nothing to special-case:

# Python, modelcontextprotocol SDK
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

params = StdioServerParameters(
    command="npx",
    args=["-y", "@xyne/spaces-mcp"],
    env={"XYNE_SPACES_BASE_URL": "https://<your-spaces-host>"},
)

async with stdio_client(params) as (read, write):
    async with ClientSession(read, write) as session:
        await session.initialize()
        tools = await session.list_tools()
        result = await session.call_tool("spaces_whoami", {})

2. Configuration. All of it is environment variables in the server's env:

Variable Default
XYNE_SPACES_BASE_URL none — required The address you open Xyne Spaces at. Without it every tool answers with what to set
XYNE_SPACES_READONLY — Overrides writes on/off for this one client: 0, false or no turns writes on, anything else keeps it read-only. See Permissions
XYNE_SPACES_TIMEOUT_MS 120000 Per-request timeout. Several operations return a whole result set — the user directory, a project's tickets — and take a while on a large workspace
XYNE_SPACES_COOKIE — Use an existing session instead of signing in. See step 3
XYNE_AGENT_DIR ~/.xyne/agent Where the session file lives

3. Sign in with Xyne SSO. Either ask the agent to run spaces_login, or run this in a terminal:

XYNE_SPACES_BASE_URL=https://<your-spaces-host> npx -y @xyne/spaces-mcp login

Both open an approval page in your browser (the link is also printed, with a short code such as BCDF-GHJK). Sign in to Spaces if asked, check the page shows the same code, and click Approve. Never approve a link someone else sent you. The session is saved to ~/.xyne/agent/spaces.json (owner-only, 0600), and a running server picks it up without a restart.

You stay signed in for as long as a Spaces browser login lasts on that deployment; spaces_whoami shows until when. The session's cookie lasts 24 hours by default, and the server renews it by itself with the refresh token saved alongside it, writing each renewal back to spaces.json. When the sign-in finally ends, or is revoked, tools say so and the agent can call spaces_login again.

Every client you connect (Claude Code, Cursor, VS Code…) runs its own server, and they all share the one saved sign-in. Each renewal replaces the refresh token, and Spaces ends a sign-in whose replaced token is used again, so renewals are coordinated: a server takes spaces.json.lock, re-reads the file, and uses a session another server already renewed rather than renewing it twice. Signing in from one client also signs in the others, on their next tool call.

To use a session you already have instead, set it as the cookie string, exactly as the browser holds it. It takes precedence over the saved session and is never renewed:

export XYNE_SPACES_COOKIE="xyne_ws_<workspaceId>_token=<token>"

4. Check it works. Ask the agent to run spaces_whoami. It should name you, your workspace, and until when you stay signed in.

Compatibility

This is a plain stdio MCP server with no host-specific code — it works with any MCP client, not just Claude Code. Concretely:

  • Transport is stdio over JSON-RPC, the baseline every client implements.
  • Protocol negotiates whatever the client asks for; verified against 2024-11-05, 2025-03-26, 2025-06-18 and 2025-11-25.
  • Capabilities are tools only — no prompts, resources, sampling or roots, so there is nothing a client has to support beyond calling a tool.
  • Results are plain text blocks, the most widely supported content type. There is no structuredContent, so no client has to understand a second encoding of the same rows.
  • Runtime is Node 22+, launched with npx. Nothing else is required.

The one thing that differs per client is how you register the server, which is the config above. Claude Code, Claude Desktop, Cursor, Windsurf, VS Code, Zed, Continue, and anything built on an MCP SDK all take the same command + args + env triple in their own config file.


Permissions

The SDK acts as the currently logged-in user. Zero's per-table ACL is folded into every read and every write, so these tools reach exactly what your Spaces user reaches — no more. A private channel you are not in does not appear in spaces_channels_list and its threads are not readable, even by id.

Two consequences worth internalising:

  • Nothing here is an admin backdoor. If an agent "cannot find" a channel, the answer is usually that the acting user is not in it.
  • Writes are real and immediate. spaces_message_send posts to a live thread that other people can see, and there is no undo from this server.

Read-only by default. Every write tool is left out of the listing until you turn writes on, from a terminal:

npx -y @xyne/spaces-mcp writes on    # agents can send messages, create threads, update tickets
npx -y @xyne/spaces-mcp writes off   # read-only again
npx -y @xyne/spaces-mcp writes       # show the current setting

The setting is "writes": true in ~/.xyne/agent/spaces.json, so one command covers every client on the computer — Claude Code, Cursor, VS Code — and running servers pick it up without a restart: they watch the file and tell their client the tool list changed, so the write tools appear or disappear on their own. Read-only means 24 tools instead of 36 (spaces_login is always there). A tool the model cannot see is a tool it cannot decide to use, which is more reliable than declining after the fact; a write call from a list made before writes were turned off is refused all the same.

Only true turns writes on: a missing field, a typo or an unreadable file keeps the server read-only. There is deliberately no tool for it — an agent that could switch on its own writes could be talked into it by text it reads in a message or ticket.

To keep one client read-only whatever the file says, set XYNE_SPACES_READONLY in that client's MCP config (-e XYNE_SPACES_READONLY=1 on claude mcp add): 0, false or no turns writes on for it, any other value keeps it read-only. It overrides the file and needs a restart of that client.


Tools

Ids are the currency. Almost every write needs an id that only a read can give you, so the reads are listed first and each one tells you what it hands the next call.

Identity and discovery

Tool Required Returns
spaces_whoami — Your user id, workspace, org, role, and when the session expires. Call this first in any session that filters or writes by user
spaces_search — Relevance-ranked hits across messages, tickets, channels, files, calls, emails, canvases, people — each carrying the ids to act on it

spaces_search is fuzzy. For an exact channel name use spaces_channels_list; for structured ticket filtering use spaces_tickets_list. Its type and apps values are validated strictly and are plural — a hit labelled [message] corresponds to type: ["messages"].

Channels and threads

Tool Required Returns
spaces_channels_list — Channels you can see: name, scope, visibility, live member count, unread count, ids. The authoritative name → id lookup
spaces_channel_participants channel_id Members with user id, email, channel role, join date
spaces_channel_create project_id A new channel, or a DM with scope_type: "DM" + dm_user
spaces_threads_list channel_id Recent threads with their opening message, reply count, participants, conversation_id
spaces_thread_get conversation_id One thread's context
spaces_thread_create channel_id, content Starts a thread. Returns the new conversation_id and message_id

Messages

Tool Required Returns
spaces_messages_list conversation_id Messages in a thread, full text, author, attachments, message_id
spaces_user_messages — Everything one person wrote, newest first, optionally date-bounded. Omit user for your own
spaces_message_send conversation_id, content Posts a reply. Returns the new message_id
spaces_message_update message_id, content Edits your own message
spaces_message_react message_id, emoji Adds or removes a reaction. Emoji by name, no colons

spaces_user_messages is an exact ordered scan, not a ranking — an empty result genuinely means they wrote nothing in that window, which repeated searches could never establish.

Tickets

Tool Required Returns
spaces_tickets_list view_mode Tickets in one scope, in full detail
spaces_tickets_search — Tickets whose key or title matches. The fastest key → id lookup
spaces_ticket_get ticket_id One ticket with tags, role assignments, related tickets, parent and sub-tickets, stage requests, RCA
spaces_ticket_activities ticket_id Change history: who moved what, when
spaces_ticket_create title, description, project_id, channel_id A new ticket. The server allocates the key (PLAT-1234). stage_name must exist on board_id; parent_ticket_id links it as a sub-ticket
spaces_ticket_update ticket_id Changes fields. Reassign with assigned_to
spaces_ticket_transition ticket_id, to_stage_name Moves a stage, picking the right path for the board
spaces_ticket_link_sub_ticket parent_ticket_id, child_ticket_id Makes an existing ticket a sub-ticket (key or id for each)
spaces_ticket_unlink_sub_ticket parent_ticket_id, child_ticket_id Detaches a sub-ticket; the ticket itself is kept

view_mode decides the scope and which companion argument is needed: my-tickets needs none, project needs project_id, board needs board_id, user-tickets needs user_id, group-tickets needs group_id. Omitting the companion is refused rather than silently returning everything.

Use spaces_ticket_transition for stage moves, not spaces_ticket_update. It reads the board type and applies the target stage's status either way; on NON_LINEAR boards it also runs the form gates and approvals that a plain field write skips.

Lookups

Tool Required Returns
spaces_projects_list — Projects with ids and key prefixes
spaces_board_stages project_id Boards with their stages in workflow order, in one call
spaces_users_list — People with user ids

Stage names must match exactly, so read them from spaces_board_stages rather than guessing at "Done" or "In Progress".

Everything else

Tool Required Returns
spaces_notifications_list — Mentions, replies, ticket changes. Narrow with types; each row shows its read state and classification
spaces_notifications_mark_read notification_id Marks one read
spaces_emails_list channel_id Emails in a desk or shared-inbox channel, with bodies
spaces_calls_list — Calls by scope: scheduled, active, or history (with recordings, transcripts, AI summaries)
spaces_drafts_list — Your unsent drafts
spaces_canvases_list — Canvases: title, owner, last editor
spaces_canvas_get canvas_id A canvas body converted to markdown
spaces_claw_list_agents — Claw agents available to this deployment
spaces_claw_run agent, task Dispatches a Claw run and waits for the answer
spaces_claw_get_run session_id Status and result of a run

Email channels are excluded from spaces_channels_list by default — pass include_email_channels to find one.


Recipes

Post into a channel by name

spaces_channels_list  { name: "payments" }        → channel_id
spaces_thread_create  { channel_id, content }     → conversation_id, message_id

To reply in an existing thread instead:

spaces_threads_list   { channel_id }              → conversation_id
spaces_message_send   { conversation_id, content }

File a ticket

spaces_projects_list  { name: "platform" }        → project_id
spaces_board_stages   { project_id }              → board_id + exact stage names
spaces_channels_list  { name: "eng" }             → channel_id
spaces_ticket_create  { title, description, project_id, board_id, channel_id }

Reassign and move a ticket

spaces_tickets_search     { query: "PLAT-1234" }              → ticket_id
spaces_ticket_update      { ticket_id, assigned_to: "someone@company.com" }
spaces_ticket_transition  { ticket_id, to_stage_name: "QA" }

assigned_to takes an email or a user id — every tool that names a person does.

Catch up on a person's week

spaces_user_messages  { user: "someone@company.com", after: "2026-08-14T00:00:00Z" }

Triage what needs you

spaces_notifications_list       { types: ["mentioned_user"] }
spaces_messages_list            { conversation_id }        ← from any notification
spaces_notifications_mark_read  { notification_id }

Errors

Failures come back as text with the API's stable error code. The API speaks five codes, one per status:

Code Status Means
validation_failed 400 An argument the server rejects, or a business rule refusing the operation (an unsupported stage move). The message says which
unauthenticated 401 Not logged in or session expired
forbidden 403 Your user is not allowed this. Not a bug in the tool
not_found 404 Absent, or invisible to you — deliberately indistinguishable. Also: no operation by that name
internal 500 A server-side failure, including search or Claw being down. Retryable

The 400 message is written for a person to read, so surface it rather than retrying. A 500 message is deliberately generic; the detail is server-side.

Anything unexpected carries the server's error code in parentheses. Quote the message and the code when reporting a server-side failure.


Also using Claw?

The Xyne Claw MCP server ships its own Claw tools behind a separate device login. If both servers are installed the model sees two Claw tool sets and may pick the one that is not authenticated. Install one or the other. The three spaces_claw_* tools here need no second login — the Spaces backend relays to Claw with the deployment's own credential.


Development

npm install
npm run build
npm run typecheck

To try a local build in a client, point it at the built file instead of npx: "command": "node", "args": ["/absolute/path/to/xyne-spaces-mcp/dist/index.js"].

Adding a tool

One entry in the relevant src/tools/*.ts, exporting a ToolDef:

{
  name: "spaces_thing_list",
  description: "…",                       // long, and directive — this is what decides selection
  inputSchema: { /* JSON Schema, snake_case, with per-field descriptions */ },
  write: false,
  async handler(args, { sdk }) { … },
}

Every call goes through @xyne/spaces-sdk, so an operation name or argument this package gets wrong is a compile error. Mark anything that changes state write: true so read-only mode can drop it.

Output is per tool, not a shared projection. Read tools emit every column that carries meaning — what matters about a ticket is not what matters about a channel — and never truncate a body. Bound the number of rows, never the content of one. src/render.ts holds the shared vocabulary: toIST, cleanText, indented, paginationFooter, and the Name <email> (id: …) user label.

Layout

src/
  index.ts        server wiring, dispatch, read-only filter, sign-in check
  config.ts       base URL and session resolution, session storage, the SDK client
  login.ts        the Xyne SSO flow shared by spaces_login and the login command
  login-command.ts  `xyne-spaces-mcp login`
  writes-command.ts `xyne-spaces-mcp writes [on|off]`
  watch.ts        follows spaces.json: the writes setting, and sign-ins made elsewhere
  errors.ts       turning a thrown SdkError into prose a model can act on
  render.ts       formatting vocabulary shared by every renderer
  tools/
    shared.ts     ToolDef, ToolContext, and the user directory (id → name, email → id)
    login.ts      spaces_login
    identity.ts   whoami, search
    channels.ts   threads.ts   messages.ts
    tickets.ts    lookups.ts   comms.ts   claw.ts

Runtime dependencies: @modelcontextprotocol/sdk for the protocol, @xyne/spaces-sdk for every call to Spaces, and emoji-datasource for reaction names. Nothing here speaks HTTP directly.

Releasing

npm version patch   # or minor
npm publish         # prepublishOnly typechecks and rebuilds first