Skip to content

Commit 657a281

Browse files
committed
Figma signs in with the team's own Figma app; its package gets the token in place of a key
1 parent 82555b2 commit 657a281

20 files changed

Lines changed: 993 additions & 35 deletions

File tree

‎docs/self-host/hybrid.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ The Setup checks show the link as `hybrid_jira` (in Settings, Setup and the inst
163163
| Jira (Forge app) | yes | install CoderHelm's Jira app and enter your install id as the team id, or link a hosted team's site ([Jira through CoderHelm](#jira-through-coderhelm)) |
164164
| Notion, Confluence, Google Drive | yes | one-click sign-in through CoderHelm; tokens brokered |
165165
| Slack and Teams notifications | not needed | your install posts to the incoming webhook you paste |
166-
| Figma, Linear, Sentry, Sanity and other sign-in apps | not needed | your install registers itself with each provider |
166+
| Figma, Linear, Sentry, Sanity and other sign-in apps | not needed | your install registers itself with each provider; Figma signs in only apps it approved, so Figma uses your own Figma app or a key |
167167
| Slack and Teams commands | no | there is no shared Slack or Teams app: each team uses its own app's signing secret, as today |
168168
| Sign in with GitHub | yes | CoderHelm's app carries the trip to GitHub; your install checks the account with GitHub and applies its own rules ([Sign in with GitHub through CoderHelm](#sign-in-with-github-through-coderhelm)) |
169169
| Sign in with Google | no | a self-hosted install has no Google sign-in, through CoderHelm or its own ([Sign-in and people](./sign-in.md#no-google-sign-in)) |

‎docs/self-host/integrations.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ New Relic, Confluence, OpenSearch, REST APIs, SQL databases, CloudWatch metrics
100100

101101
- **What you need**\
102102
Nothing. Servers that support OAuth dynamic client registration register your install by themselves the first time someone signs in. The redirect URI is your install's `https://coderhelm.example.com/settings/integrations/mcp-callback/`, and the add flow shows it for servers that need an app registered by hand.
103+
- **Figma**\
104+
Figma's MCP server signs in only apps Figma approved, so CoderHelm runs Figma's tools with your own Figma app (or a personal access token). Create the app at https://www.figma.com/developers/apps under your Figma team or organization, add the redirect URI above, give it the `current_user:read` and `file_content:read` scopes, and publish it as a private app (no review from Figma; people in that team or organization can sign in). Paste its client id and secret in Settings, Integrations, Figma, Use my own Figma app, then select Connect.
103105
- **With hybrid**\
104106
No change: MCP sign-ins always go to your install directly.
105107

‎services/common/src/hybrid/integrations.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub const CATALOG: &[Entry] = &[
9292
id: "mcp_apps",
9393
name: "Figma, Linear, Sentry, Sanity and other sign-in apps",
9494
mode: Mode::Direct,
95-
through_coderhelm: "Nothing: your install registers itself with each provider's sign-in server and keeps its own tokens.",
95+
through_coderhelm: "Nothing: your install registers itself with each provider's sign-in server and keeps its own tokens. Figma signs in only apps it approved, so Figma uses your own Figma app or a key.",
9696
stays_with_you: "Everything.",
9797
reason: "",
9898
},

‎services/common/src/knowledge/sources/oauth.rs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ pub fn connection_record(
303303
.map(|(k, v)| (k.to_string(), v.to_string()))
304304
.collect(),
305305
token_body_json: p.json_body,
306+
refresh_endpoint: String::new(),
306307
});
307308
s
308309
}
@@ -346,6 +347,7 @@ pub fn brokered_connection_record(
346347
legacy: false,
347348
extra_authorize: vec![],
348349
token_body_json: false,
350+
refresh_endpoint: String::new(),
349351
});
350352
s
351353
}

‎services/common/src/mcp_catalog.rs‎

Lines changed: 87 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ pub const CATALOG: &[McpServerDef] = &[
6666
recommended_permissions: "Read-only file access",
6767
npx_package: "figma-developer-mcp",
6868
// No remote sign-in: Figma's MCP server registers only clients Figma
69-
// approved (dynamic registration answers 403) and takes no client
70-
// metadata documents, so a key is the way in.
69+
// approved (dynamic registration answers 403, and its `mcp:connect`
70+
// scope is refused to any other app) and takes no client metadata
71+
// documents. The package reads Figma's REST API, which takes a key or
72+
// a token from the team's own Figma OAuth app ([`own_app`]).
7173
remote_url: "",
7274
remote_key: false,
7375
key_unavailable: "",
@@ -562,6 +564,59 @@ pub fn key_help(id: &str) -> Option<String> {
562564
))
563565
}
564566

567+
/// A team's own OAuth app with a vendor whose package reads the vendor's
568+
/// API with an OAuth token as well as a key. The team registers the app with
569+
/// the vendor and pastes its client id and secret; a sign-in then gives the
570+
/// package a token in place of a key, renewed before it expires.
571+
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
572+
pub struct OwnApp {
573+
/// Where people approve the app.
574+
pub authorize: &'static str,
575+
/// Where a code is exchanged for tokens.
576+
pub token: &'static str,
577+
/// Where a refresh token is exchanged, when the vendor uses a separate
578+
/// address for it. Empty means [`OwnApp::token`].
579+
pub refresh: &'static str,
580+
/// Exactly what the package (and the connection check) calls.
581+
pub scopes: &'static [&'static str],
582+
/// The environment variable the package reads the token from.
583+
#[serde(skip)]
584+
pub env_var: &'static str,
585+
/// Asked with the token after a sign-in to confirm it works.
586+
#[serde(skip)]
587+
pub check: &'static str,
588+
/// Where the team creates the app.
589+
pub console: &'static str,
590+
/// The vendor's guide to creating one.
591+
pub guide: &'static str,
592+
}
593+
594+
/// The own-app sign-in for a catalog server, when its package takes an
595+
/// OAuth token.
596+
pub fn own_app(id: &str) -> Option<OwnApp> {
597+
match id {
598+
// Figma's REST API takes tokens from any OAuth app, and a private
599+
// app needs no review from Figma for people on the team or
600+
// organization that owns it. The token endpoint wants the client in
601+
// an HTTP Basic header; refreshing has its own address and never
602+
// rotates the refresh token. The package calls GET /v1/files,
603+
// /v1/files/:key/nodes, /v1/images and /v1/files/:key/images (all
604+
// file_content:read); the check calls GET /v1/me (current_user:read).
605+
// `figma_own_app_asks_for_what_the_package_calls` pins this list.
606+
"figma" => Some(OwnApp {
607+
authorize: "https://www.figma.com/oauth",
608+
token: "https://api.figma.com/v1/oauth/token",
609+
refresh: "https://api.figma.com/v1/oauth/refresh",
610+
scopes: &["current_user:read", "file_content:read"],
611+
env_var: "FIGMA_OAUTH_TOKEN",
612+
check: "https://api.figma.com/v1/me",
613+
console: "https://www.figma.com/developers/apps",
614+
guide: "https://developers.figma.com/docs/rest-api/oauth-apps/",
615+
}),
616+
_ => None,
617+
}
618+
}
619+
565620
/// The catalog's server ids, in catalog order.
566621
pub fn ids() -> impl Iterator<Item = &'static str> {
567622
CATALOG.iter().map(|p| p.id)
@@ -617,6 +672,36 @@ mod tests {
617672
assert_eq!(find("nope").map(|p| p.id), None);
618673
}
619674

675+
#[test]
676+
fn an_own_app_is_only_for_a_package_that_reads_its_token() {
677+
for p in CATALOG {
678+
let Some(app) = own_app(p.id) else { continue };
679+
// The token goes to the package, so there must be one.
680+
assert!(!p.npx_package.is_empty(), "{}", p.id);
681+
assert!(
682+
!app.env_var.is_empty() && !app.scopes.is_empty(),
683+
"{}",
684+
p.id
685+
);
686+
for u in [app.authorize, app.token, app.check, app.console] {
687+
assert!(u.starts_with("https://"), "{}: {u}", p.id);
688+
}
689+
assert!(app.refresh.is_empty() || app.refresh.starts_with("https://"));
690+
}
691+
assert!(own_app("sentry").is_none());
692+
}
693+
694+
#[test]
695+
fn figma_own_app_asks_for_what_the_package_calls() {
696+
let app = own_app("figma").unwrap();
697+
assert_eq!(app.scopes, &["current_user:read", "file_content:read"]);
698+
// figma-developer-mcp sends FIGMA_OAUTH_TOKEN as a bearer token
699+
// (and FIGMA_API_KEY as X-Figma-Token).
700+
assert_eq!(app.env_var, "FIGMA_OAUTH_TOKEN");
701+
assert_eq!(find("figma").unwrap().npx_package, "figma-developer-mcp");
702+
assert_eq!(app.refresh, "https://api.figma.com/v1/oauth/refresh");
703+
}
704+
620705
#[test]
621706
fn the_proxy_allowlist_is_exactly_the_catalogs_packages() {
622707
// Every package the catalog runs is allowed, and nothing else is: a

‎services/common/src/mcp_remote/mod.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@
1616
//! - [`tools`]: the allow list and its second-admin approval.
1717
//! - [`store`]: the records, sealed where they hold secrets.
1818
//! - [`runtime`]: everything above put together for the gateway and worker.
19+
//! - [`own_app`]: a team's own OAuth app for a catalog package that reads
20+
//! the vendor's API with a token (Figma), signed in to the same way.
1921
//!
2022
//! A token Coderhelm gets for a server is sent to that server only, and is
21-
//! never handed to a model or passed through to anything else.
23+
//! never handed to a model or passed through to anything else. An own-app
24+
//! token goes only to the vendor's API, through the vendor's package.
2225
2326
pub mod client;
2427
pub mod discovery;
2528
pub mod http;
2629
pub mod oauth;
30+
pub mod own_app;
2731
pub mod runtime;
2832
pub mod store;
2933
pub mod tools;

0 commit comments

Comments
 (0)