Skip to content

feat(mcp): @superagentskill/sdk + i18n shim for /oauth/success - #20

Merged
criptogus merged 1 commit into
mainfrom
claude/mcp-roadmap-slice-2
May 23, 2026
Merged

criptogus merged 1 commit into
mainfrom
claude/mcp-roadmap-slice-2

Conversation

@criptogus

Copy link
Copy Markdown
Owner

Slice 2 of the MCP UX roadmap. Two of the three planned items land here; the third (notifications/resources/list_changed) is deferred — see below.

1. @superagentskill/sdk — TypeScript SDK

New package at packages/sdk-ts/. Thin, strongly-typed client for the public MCP endpoint that handles the three friction points integrators hit by hand:

import { SuperAgentSkill, idempotencyKey } from "@superagentskill/sdk";

const sas = new SuperAgentSkill({ token: process.env.SAS_TOKEN });
const out = await sas.call("search_registry", { query: "cardiology" });
//    ^? typed as SearchRegistryOutput

await sas.call("upload_packages", {
  files: [...],
  idempotency_key: idempotencyKey(["upload-batch-1", "v1"]),
});

console.log(sas.lastRateLimit);
// → { limit: 100, remaining: 87, resetAtUnix: 1716508800 }
  • Headers — sets Accept: application/json, text/event-stream so callers don't trip the 406 footgun.
  • Auth — Bearer + typed MCPUnauthorizedError carrying the authorization_url / tokens_url hints from the server.
  • Retries — 3 attempts by default, honours Retry-After on 429s, exponential backoff on 5xx / network errors.
  • Rate-limit visibility — sas.lastRateLimit parsed from X-RateLimit-* headers (added in slice 1).
  • Idempotency — idempotencyKey() helper builds stable keys for write-tool retries (relies on slice 1's mcp_idempotency table).
  • Strong types — ToolMap covers every tool today; adding one means updating one file.

Build: cd packages/sdk-ts && npm run build. Publish: npm publish --access public.

2. i18n shim — /oauth/success in EN / PT-BR

Most of our inbound is Brazilian, but every new user lands on the connection-success page in English. Now they get a tiny EN / PT switcher and Portuguese copy. Translations live in src/lib/i18n/dictionaries.ts; resolution is via useLang() (localStorage → navigator.language → en).

Intentionally minimal — no i18next, no provider, no per-request cookie. When/if we localise the full site we can swap the implementation; the dictionaries don't change.

3. Deferred: notifications/resources/list_changed

Investigated mcp-tanstack-start. Server→client push notifications require stateful mode (per-session storage), which is not currently configured for this server. Enabling it touches infrastructure (session store choice — in-memory single-instance vs Redis-backed) and is worth its own PR with its own review. Filed as a follow-up.

Files

  • packages/sdk-ts/{package.json,tsconfig.json,README.md,src/index.ts,src/types.ts} (new)
  • src/lib/i18n/{index.ts,dictionaries.ts} (new)
  • src/hooks/use-lang.ts (new)
  • src/routes/oauth.success.tsx — translated copy, language switcher

Test plan

  • cd packages/sdk-ts && npm run build succeeds; node -e "console.log(require('./dist/index.js').SuperAgentSkill)" prints a function.
  • In an external project: npm install ../agent-evolve-network/packages/sdk-ts && node -e "import('@superagentskill/sdk').then(({ SuperAgentSkill }) => new SuperAgentSkill().call('list_packages', { limit: 3 }).then(console.log))".
  • Visit /oauth/success with browser language=pt-BR → page renders in Portuguese. Toggle switcher → flips to English, persists across reload.
  • Visit with English browser → defaults to English. Toggle to PT → persists.

https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd


Generated by Claude Code

Slice 2 of the MCP UX roadmap.

## packages/sdk-ts — @superagentskill/sdk

Thin, strongly-typed client for the public MCP endpoint:

  import { SuperAgentSkill, idempotencyKey } from "@superagentskill/sdk";
  const sas = new SuperAgentSkill({ token: process.env.SAS_TOKEN });
  const out = await sas.call("search_registry", { query: "cardiology" });

Handles the three friction points integrators hit by hand:

* Headers — sets Accept: application/json, text/event-stream so callers
  don't trip the 406 footgun.
* Auth — Bearer token + typed MCPUnauthorizedError carrying the
  authorization_url / tokens_url hints the server emits.
* Retries — 3 attempts by default, honours Retry-After on 429s,
  exponential backoff on 5xx / network errors.

Also surfaces X-RateLimit-* headers as `sas.lastRateLimit` so callers
can self-regulate before hitting the ceiling, and exposes a tiny
`idempotencyKey()` helper for stable write-tool retries.

ToolMap covers every tool the server currently exposes; adding a tool
means updating one file so the SDK never drifts from the wire format.

## src/lib/i18n + /oauth/success in EN/PT-BR

Minimal locale shim (no i18next, no provider) because the rest of the
site is engineering-targeted English and only a handful of pages
deserve translation today. `useLang` resolves from localStorage,
falls back to navigator.language, falls back to en; renders a small
EN / PT switcher on /oauth/success so PT-BR users (the bulk of our
inbound) finally see "Conectado a Cursor" instead of "Connected to".

Notifications/resources/list_changed deferred — mcp-tanstack-start
exposes server→client push only in stateful mode (not currently
configured); we'll wire it in a follow-up once we decide on a session
store.

https://claude.ai/code/session_019gMoupKKTVydpNwiiACQRd
@criptogus
criptogus marked this pull request as ready for review May 23, 2026 01:47
@criptogus
criptogus merged commit d04ebc4 into main May 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants