MCP: user lookup + add/list collaborators so Claude Tag can share docs it creates

Open
#98 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

  • #145 by @maxsam4 — closed without merging

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
typescript
Domain
api, backend

Research direction

Start with the REST collaborator and user-lookup routes, then read apps/api/src/routes/events.ts for the g.mayWrite check. Extract the permission, validation and notification logic from REST into one shared function that both REST and the new MCP tools call, and read apps/api/src/mcp/tools.test.ts for the existing tool test pattern. Done when primer_lookup_user, primer_add_collaborator and primer_list_collaborators pass the listed guardrail tests, and REST behaviour is unchanged. Closed, unmerged PR #145 is linked, so check why it was closed before starting.

Written by the indexing model from the issue text.

Description

agent-ready enhancement in-progress

Problem

A Claude Tag session (Claude in Slack) can create a Primer document over MCP, but no one else can work on it afterwards.

  • primer_create_document makes the caller the document's owner. Claude Tag's MCP connection authenticates as the seeded service user service-claude, so service-claude owns every document Claude Tag creates.
  • Writing events (POST /api/documents/:id/events, apps/api/src/routes/events.ts) requires the owner or a collaborator (g.mayWrite). This is also how PADD review packets record a human's Send/verdict.
  • So when a human pressed Send on a Claude Tag-published PADD, Primer returned 403 {"error":"forbidden"}. That person was not a collaborator, and Claude Tag had no way to make them one.

The REST API already supports all of this:

  • GET /api/users/lookup?email=
  • GET and POST /api/documents/:docId/collaborators

But the MCP server exposes none of it. Claude Tag's sandbox can only reach Primer through MCP, because the Agent Proxy injects the bearer credential for /mcp only.

Local Claude Code sessions don't hit this. They create documents as the human, using the human's own token.

Use case

A Claude Tag session publishes a document (a PADD review packet, for example) on behalf of the person who asked for it. It then gives that person, and any other named reviewers, the access they need to read, comment, and send events. All of this happens over MCP, with no REST access and no human doing manual sharing in the UI.

Proposed MCP tools

All three tools must enforce the same permission checks, validation, and side effects as the REST routes they mirror. They are a second door onto existing behaviour, not new behaviour.

Tool Mirrors Input Returns
primer_lookup_user GET /api/users/lookup?email= email { id, email, displayName }, or a clear not-found result
primer_add_collaborator POST /api/documents/:docId/collaborators documentId (or a Primer URL, resolved like the other tools), email or userId, role (editor | commenter) the collaborator row
primer_list_collaborators GET /api/documents/:docId/collaborators documentId (or a Primer URL) the collaborator list

Guardrails (acceptance criteria)

  • Owner only. primer_add_collaborator and primer_list_collaborators require canManage, the same check as REST. For Claude Tag this means only documents the service account created. It can never grant access to someone else's document.
  • Add only. No MCP tool to change a role, remove a collaborator, change visibility, or transfer ownership. Re-adding an existing collaborator matches REST behaviour (conflict or no-op, whichever REST does today).
  • Rule parity. Visibility rules match REST: an org-visible document rejects commenter with invalid_role_for_visibility.
  • Not the service account. Adding service-claude (the caller itself) is rejected.
  • Unknown emails fail clearly. An email with no Primer user returns a clear not-found error. The tool does not create users.
  • Notification parity. The collaborator-added notification (notifier.notifyCollaboratorAdded) fires exactly as it does from REST, so the added person learns about the document.
  • One implementation. REST and MCP share the logic, extracted into one function. There is no second copy of the permission or validation code that could drift.
  • Tests. Tool tests in apps/api/src/mcp/tools.test.ts cover:
    • success
    • non-owner → forbidden
    • org document + commenter → rejected
    • unknown email
    • adding the service account
    • adding a duplicate
    • notification sent
  • Docs. Tool descriptions say these are for sharing a document the caller created with the person who asked for it.

Out of scope / known limitations

  • Shared service account. Every Claude Tag user acts as the same service-claude principal. Any Tag user could ask Claude to share any Tag-created document. Owner-only checks narrow this but don't remove it. Per-requester identity (see #45, and Claude Tag personal connectors) is the real fix.
  • Submit-only role. Org documents force reviewers to be editor, which also lets them publish new versions. Whether PADD reviewers need a role that can send events without publishing versions is a separate design decision.
  • Image size limit. Inline images in PADDs hit the 256KB limit; tracked in #87.
  • No ownership transfer. Ownership transfer is not needed for this use case.
Dominant language
TypeScript
Stars
2
Forks
1
Avg merge
13h 38m
Merged PRs (30d)
24

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 0xPolygon/primer

All issues in 0xPolygon/primer

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.