Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/self-host/hybrid.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ The Setup checks show the link as `hybrid_jira` (in Settings, Setup and the inst
| 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)) |
| Notion, Confluence, Google Drive | yes | one-click sign-in through CoderHelm; tokens brokered |
| Slack and Teams notifications | not needed | your install posts to the incoming webhook you paste |
| Figma, Linear, Sentry, Sanity and other sign-in apps | not needed | your install registers itself with each provider |
| 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 |
| Slack and Teams commands | no | there is no shared Slack or Teams app: each team uses its own app's signing secret, as today |
| 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)) |
| 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)) |
Expand Down
2 changes: 2 additions & 0 deletions docs/self-host/integrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ New Relic, Confluence, OpenSearch, REST APIs, SQL databases, CloudWatch metrics

- **What you need**\
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.
- **Figma**\
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.
- **With hybrid**\
No change: MCP sign-ins always go to your install directly.

Expand Down
2 changes: 1 addition & 1 deletion services/common/src/hybrid/integrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ pub const CATALOG: &[Entry] = &[
id: "mcp_apps",
name: "Figma, Linear, Sentry, Sanity and other sign-in apps",
mode: Mode::Direct,
through_coderhelm: "Nothing: your install registers itself with each provider's sign-in server and keeps its own tokens.",
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.",
stays_with_you: "Everything.",
reason: "",
},
Expand Down
2 changes: 2 additions & 0 deletions services/common/src/knowledge/sources/oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ pub fn connection_record(
.map(|(k, v)| (k.to_string(), v.to_string()))
.collect(),
token_body_json: p.json_body,
refresh_endpoint: String::new(),
});
s
}
Expand Down Expand Up @@ -346,6 +347,7 @@ pub fn brokered_connection_record(
legacy: false,
extra_authorize: vec![],
token_body_json: false,
refresh_endpoint: String::new(),
});
s
}
Expand Down
89 changes: 87 additions & 2 deletions services/common/src/mcp_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,10 @@ pub const CATALOG: &[McpServerDef] = &[
recommended_permissions: "Read-only file access",
npx_package: "figma-developer-mcp",
// No remote sign-in: Figma's MCP server registers only clients Figma
// approved (dynamic registration answers 403) and takes no client
// metadata documents, so a key is the way in.
// approved (dynamic registration answers 403, and its `mcp:connect`
// scope is refused to any other app) and takes no client metadata
// documents. The package reads Figma's REST API, which takes a key or
// a token from the team's own Figma OAuth app ([`own_app`]).
remote_url: "",
remote_key: false,
key_unavailable: "",
Expand Down Expand Up @@ -562,6 +564,59 @@ pub fn key_help(id: &str) -> Option<String> {
))
}

/// A team's own OAuth app with a vendor whose package reads the vendor's
/// API with an OAuth token as well as a key. The team registers the app with
/// the vendor and pastes its client id and secret; a sign-in then gives the
/// package a token in place of a key, renewed before it expires.
#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize)]
pub struct OwnApp {
/// Where people approve the app.
pub authorize: &'static str,
/// Where a code is exchanged for tokens.
pub token: &'static str,
/// Where a refresh token is exchanged, when the vendor uses a separate
/// address for it. Empty means [`OwnApp::token`].
pub refresh: &'static str,
/// Exactly what the package (and the connection check) calls.
pub scopes: &'static [&'static str],
/// The environment variable the package reads the token from.
#[serde(skip)]
pub env_var: &'static str,
/// Asked with the token after a sign-in to confirm it works.
#[serde(skip)]
pub check: &'static str,
/// Where the team creates the app.
pub console: &'static str,
/// The vendor's guide to creating one.
pub guide: &'static str,
}

/// The own-app sign-in for a catalog server, when its package takes an
/// OAuth token.
pub fn own_app(id: &str) -> Option<OwnApp> {
match id {
// Figma's REST API takes tokens from any OAuth app, and a private
// app needs no review from Figma for people on the team or
// organization that owns it. The token endpoint wants the client in
// an HTTP Basic header; refreshing has its own address and never
// rotates the refresh token. The package calls GET /v1/files,
// /v1/files/:key/nodes, /v1/images and /v1/files/:key/images (all
// file_content:read); the check calls GET /v1/me (current_user:read).
// `figma_own_app_asks_for_what_the_package_calls` pins this list.
"figma" => Some(OwnApp {
authorize: "https://www.figma.com/oauth",
token: "https://api.figma.com/v1/oauth/token",
refresh: "https://api.figma.com/v1/oauth/refresh",
scopes: &["current_user:read", "file_content:read"],
env_var: "FIGMA_OAUTH_TOKEN",
check: "https://api.figma.com/v1/me",
console: "https://www.figma.com/developers/apps",
guide: "https://developers.figma.com/docs/rest-api/oauth-apps/",
}),
_ => None,
}
}

/// The catalog's server ids, in catalog order.
pub fn ids() -> impl Iterator<Item = &'static str> {
CATALOG.iter().map(|p| p.id)
Expand Down Expand Up @@ -617,6 +672,36 @@ mod tests {
assert_eq!(find("nope").map(|p| p.id), None);
}

#[test]
fn an_own_app_is_only_for_a_package_that_reads_its_token() {
for p in CATALOG {
let Some(app) = own_app(p.id) else { continue };
// The token goes to the package, so there must be one.
assert!(!p.npx_package.is_empty(), "{}", p.id);
assert!(
!app.env_var.is_empty() && !app.scopes.is_empty(),
"{}",
p.id
);
for u in [app.authorize, app.token, app.check, app.console] {
assert!(u.starts_with("https://"), "{}: {u}", p.id);
}
assert!(app.refresh.is_empty() || app.refresh.starts_with("https://"));
}
assert!(own_app("sentry").is_none());
}

#[test]
fn figma_own_app_asks_for_what_the_package_calls() {
let app = own_app("figma").unwrap();
assert_eq!(app.scopes, &["current_user:read", "file_content:read"]);
// figma-developer-mcp sends FIGMA_OAUTH_TOKEN as a bearer token
// (and FIGMA_API_KEY as X-Figma-Token).
assert_eq!(app.env_var, "FIGMA_OAUTH_TOKEN");
assert_eq!(find("figma").unwrap().npx_package, "figma-developer-mcp");
assert_eq!(app.refresh, "https://api.figma.com/v1/oauth/refresh");
}

#[test]
fn the_proxy_allowlist_is_exactly_the_catalogs_packages() {
// Every package the catalog runs is allowed, and nothing else is: a
Expand Down
6 changes: 5 additions & 1 deletion services/common/src/mcp_remote/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@
//! - [`tools`]: the allow list and its second-admin approval.
//! - [`store`]: the records, sealed where they hold secrets.
//! - [`runtime`]: everything above put together for the gateway and worker.
//! - [`own_app`]: a team's own OAuth app for a catalog package that reads
//! the vendor's API with a token (Figma), signed in to the same way.
//!
//! A token Coderhelm gets for a server is sent to that server only, and is
//! never handed to a model or passed through to anything else.
//! never handed to a model or passed through to anything else. An own-app
//! token goes only to the vendor's API, through the vendor's package.
pub mod client;
pub mod discovery;
pub mod http;
pub mod oauth;
pub mod own_app;
pub mod runtime;
pub mod store;
pub mod tools;
Loading
Loading