fix(slack-relay): sessions tools keep every item and cursor; name people and filter by person

Merged
KH
5d ago
+308-33

Follow-up to #437, which already merged. It fixes bugs the reviewers found and adds person names, which live feedback asked for.

Fixes

  • Paging (sessions-mcp.ts bounded()): to fit the 24 000-character output cap, it dropped items from a page but kept next_cursor. That cursor points past the whole page, so the dropped items could never be read. Now only strings are cut, down to 20 characters. If the page still doesn't fit, the agent gets an error asking for a smaller limit. next_cursor is never cut either; it is passed back whole.
  • Name collision (main.ts): an OAuth MCP server named sessions overwrote the built-in tools. It is now skipped, with a log line.

Names and a person filter

  • The agent reported that the session list showed only opaque user IDs. The host now lists the organization's members from relay-control with GET /api/v1/organizations/<org>/memberships. Any org member may call it, with no admin role needed (organizationAccess(…, admin=false) for GET). The call uses the uploader user's sh_at_, and the list is cached for 10 minutes; if a refresh fails, the last list is kept. The agent's MCP server fetches the list through the loopback proxy at GET /members, so no credential is involved on its side.
  • Each session, search hit and get_session metadata now carries user: {id, name, email}. IDs that no member has stay bare IDs.
  • list_sessions and search_sessions take a person filter, which matches any of:
    • a name or part of one;
    • an email;
    • an email's local part (e.g. nt).
  • The filter runs in the tools, so each call reads up to 5 whole pages and stops at a page boundary; the cursor skips nothing. If no member matches, the tool returns a clear error. Agents can see members' names and email addresses.

Versions

slack-relay 0.3.9 and agent-relay 0.7.47. These skip 0.3.8/0.7.46, which #438 is taking. Registry rows and the regenerated doc are included.

Tests

npm test passes 73/73. Coverage includes:

  • the cursor coming back uncut;
  • no items dropped from a page;
  • name resolution, with unknown IDs left as IDs;
  • caching: one memberships read across several calls;
  • the person filter by email local part, email and name fragment, across pages;
  • the 401 refresh and the keep-last-list fallback.

Not verified live: the memberships call with the uploader's device token. It was checked in the relay-control source only.

šŸ¤– Generated with Claude Code