MCPcopy Index your code
hub / github.com/discord/embedded-app-sdk

github.com/discord/embedded-app-sdk @v2.5.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.5.0 ↗ · + Follow
151 symbols 323 edges 62 files 18 documented · 12% updated 2mo agov2.5.0 · 2026-05-05★ 1,40122 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

@discord/embedded-app-sdk

Discord Embedded App SDK

The Embedded App SDK enables you to build rich, multiplayer experiences inside Discord.

Activities are multiplayer games and social experiences in Discord. An Activity is a web application hosted in an iframe that can run within the Discord client on desktop, web, or mobile. The Embedded App SDK handles the communication between Discord and your iframed application.

Read more about building Discord Activities with the Embedded App SDK on https://docs.discord.com/developers/activities/overview.

Resources

Installing this package

npm install @discord/embedded-app-sdk

Usage

To use the SDK, import it into your project and construct a new instance of the DiscordSDK class.

Below is a minimal example of setting up the SDK. Visit https://github.com/discord/embedded-app-sdk-examples/tree/main/discord-activity-starter for a complete example application. See more info on environment variables (YOUR_OAUTH2_CLIENT_ID, etc...) here.

import {DiscordSDK} from '@discord/embedded-app-sdk';
const discordSdk = new DiscordSDK(YOUR_OAUTH2_CLIENT_ID);

async function setup() {
  // Wait for READY payload from the discord client
  await discordSdk.ready();

  // Pop open the OAuth permission modal and request for access to scopes listed in scope array below
  const {code} = await discordSdk.commands.authorize({
    client_id: YOUR_OAUTH2_CLIENT_ID,
    response_type: 'code',
    state: '',
    prompt: 'none',
    scope: ['identify', 'applications.commands'],
  });

  // Retrieve an access_token from your application's server
  const response = await fetch('/.proxy/api/token', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      code,
    }),
  });
  const {access_token} = await response.json();

  // Authenticate with Discord client (using the access_token)
  auth = await discordSdk.commands.authenticate({
    access_token,
  });
}

SDK development

Developing a new feature or patching a bug on the SDK? Check out this guide to learn how to set up your local dev environment.

Discord Developer Terms of Service & Developer Policy

Please note that while this SDK is licensed under the MIT License, the Discord Developer Terms of Service and Discord Developer Policy otherwise still apply to you and the applications you develop utilizing this SDK.

Extension points exported contracts — how you extend this code

IDiscordSDK (Interface)
(no doc) [4 implementers]
src/interface.ts
ISDKError (Interface)
(no doc) [1 implementers]
src/error.ts
BigInt (Interface)
(no doc) [1 implementers]
src/utils/BigFlagUtils.ts
HandshakePayload (Interface)
(no doc)
src/Discord.ts
CaptureLogInput (Interface)
(no doc)
src/commands/captureLog.ts
EventArgs (Interface)
(no doc)
src/schema/events.ts
SdkConfiguration (Interface)
(no doc)
src/interface.ts
MatchAndRewriteURLInputs (Interface)
(no doc)
src/utils/url.ts

Core symbols most depended-on inside this repo

toString
called by 26
src/utils/BigFlagUtils.ts
zodCoerceUnhandledValue
called by 26
src/utils/zodUtils.ts
commandFactory
called by 14
src/utils/commandFactory.ts
schemaCommandFactory
called by 13
src/utils/commandFactory.ts
attemptRemap
called by 11
src/utils/patchUrlMappings.ts
matchAndRewriteURL
called by 9
src/utils/url.ts
absoluteURL
called by 7
src/utils/url.ts
or
called by 5
src/utils/BigFlagUtils.ts

Shape

Function 70
Method 41
Interface 21
Class 10
Enum 9

Languages

TypeScript100%

Modules by API surface

src/utils/BigFlagUtils.ts23 symbols
src/Discord.ts21 symbols
scripts/syncRPCSchema.mjs14 symbols
src/utils/patchUrlMappings.ts12 symbols
src/mock.ts10 symbols
src/interface.ts6 symbols
src/utils/zodUtils.ts5 symbols
src/utils/url.ts4 symbols
src/error.ts4 symbols
src/commands/setOrientationLockState.ts4 symbols
src/Constants.ts4 symbols
src/schema/events.ts3 symbols

For agents

$ claude mcp add embedded-app-sdk \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact