Get App Source
Use this to read an App's stored source and current revision before editing it.
MCP name: get_app_source
Tool contract
{
"annotations": {
"destructiveHint": false,
"openWorldHint": false,
"readOnlyHint": true,
"title": "Get App Source"
},
"description": "Use this to read an App's stored source and current revision before editing it. Pass that revision to update_app as `expected_revision`; read a large App one `bucket` at a time.",
"execution": {
"taskSupport": "forbidden"
},
"inputSchema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"properties": {
"app_id": {
"description": "The app ID (UUID)",
"format": "uuid",
"pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$",
"type": "string"
},
"bucket": {
"description": "Read one source bucket in chunks of up to 20000 characters of whole lines, returned in `chunk`, instead of the whole source. Use it when the whole source is too large for your client (check `sourceSize`). An absent bucket reads as empty text.",
"enum": [
"module",
"ui",
"styles"
],
"type": "string"
},
"expected_revision": {
"description": "Revision from your first read. The read fails with revision_mismatch if the app has changed since, so paged chunks all come from one revision.",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer"
},
"offset": {
"description": "Character offset into `bucket`, from the prior read's `chunk.next_offset`; keep reading until it is null. Defaults to 0. Requires `bucket`.",
"maximum": 9007199254740991,
"minimum": 0,
"type": "integer"
}
},
"required": [
"app_id"
],
"type": "object"
},
"name": "get_app_source",
"outputSchema": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"additionalProperties": false,
"properties": {
"$schema": {
"description": "Exact manifest schema URL. Omitted for legacy apps.",
"type": "string"
},
"activeRevision": {
"description": "The revision visitors are served. Equal to `revision` once the latest save is live. When lower, the source in this response is not live yet; `build` says why. While `build.state` is queued, resolving, building, or validating, wait for it to finish. When it is failed or expired, read `build.error`: `stage` names the build stage that failed and `path`, `line`, and `column` the file position when known; fix that save and save again, or restore the active revision. When it is canceled, save again to build it, or restore the active revision. When it is superseded, read the source again. When `build` is null, Charming has no build on record for this save: a save before packages stored without one, or a package save whose build record is gone. Save it again to build and publish it. `publication` names the state: `unpublished` means Charming holds the save without a runnable build while `activeRevision` keeps serving. `activeRevision` and `build` are read separately, so a build that publishes between them can show a lower `activeRevision` with `build.state` published; the next read agrees.",
"maximum": 9007199254740991,
"minimum": 0,
"type": "integer"
},
"advisories": {
"description": "Structured non-fatal advisories, including authoring issues and unread staff feedback responses. Each advisory.summary is also appended to the text content for the LLM path.",
"items": {
"additionalProperties": false,
"properties": {
"data": {
"additionalProperties": {},
"description": "Kind-specific structured payload. Shape varies per advisory kind.",
"propertyNames": {
"type": "string"
},
"type": "object"
},
"doc_url": {
"description": "Optional docs pointer for this advisory kind.",
"type": "string"
},
"kind": {
"description": "Stable advisory identifier (e.g. \"legacy-bridge\").",
"type": "string"
},
"severity": {
"description": "Severity; omitted advisories are treated as 'info'.",
"enum": [
"info",
"warn"
],
"type": "string"
},
"summary": {
"description": "Agent-facing summary. Self-sufficient; no extra context required.",
"type": "string"
},
"userSummary": {
"description": "End-user-facing summary. Set when the advisory should render in-app.",
"type": "string"
}
},
"required": [
"kind",
"summary"
],
"type": "object"
},
"type": "array"
},
"appVersion": {
"description": "Canonical apps return decimal String(revision). Legacy apps return their stored effective SemVer.",
"type": "string"
},
"build": {
"anyOf": [
{
"additionalProperties": false,
"properties": {
"buildId": {
"description": "Build ID. Pass it to get_app_build for the full status.",
"type": "string"
},
"error": {
"additionalProperties": false,
"description": "Why the build ended without publishing. Present when it failed or expired.",
"properties": {
"column": {
"description": "The 1-based column in `line`.",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer"
},
"details": {
"anyOf": [
{
"additionalProperties": false,
"properties": {
"execution": {
"enum": [
"not_started",
"may_have_run"
],
"type": "string"
},
"operationId": {
"minLength": 1,
"type": "string"
},
"reservationId": {
"minLength": 1,
"type": "string"
}
},
"required": [
"execution",
"operationId"
],
"type": "object"
},
{
"additionalProperties": false,
"properties": {
"execution": {
"const": "may_have_run",
"type": "string"
}
},
"required": [
"execution"
],
"type": "object"
}
]
},
"kind": {
"type": "string"
},
"line": {
"description": "The 1-based line in `path`.",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer"
},
"message": {
"type": "string"
},
"path": {
"description": "The App file the failure points at, relative to the package root, when it points at one of the App's own files.",
"type": "string"
},
"retryable": {
"type": "boolean"
},
"specifier": {
"type": "string"
},
"stage": {
"description": "A stage only when the author's package caused the failure. `source`: the package was refused (its files, imports, or package.json, a size cap, a refused `connect-src` origin, a package name another App holds or that differs from the App's, or accepted source the current contract refuses); fix what the message names, in the file `path` names when given. `dependencies`: npm could not resolve or install the declared dependencies, or the tree has more packages than the limit; fix the package `specifier` names when given, its range in package.json, or trim the dependencies. `compile`: the compiler, or the check of the built server module, refused the App's code; fix the file and position named when given. Every other failure has no stage, because nothing in the package would fix it: a build sandbox, provider, executor, or database failing, a busy host, a cancellation, lost authority, an expired build or one that used up its attempts, an input Charming could not load, or a copy whose requested manifest id was taken. Save again.",
"enum": [
"source",
"dependencies",
"compile"
],
"type": "string"
},
"target": {
"type": "string"
}
},
"required": [
"kind",
"message",
"retryable"
],
"type": "object"
},
"state": {
"enum": [
"queued",
"resolving",
"building",
"validating",
"published",
"failed",
"superseded",
"canceled",
"expired"
],
"type": "string"
},
"statusUrl": {
"description": "Authenticated HTTP status URL for this build.",
"type": "string"
}
},
"required": [
"buildId",
"state",
"statusUrl"
],
"type": "object"
},
{
"type": "null"
}
],
"description": "The build a save accepted for `revision`. Null when no build is recorded against this revision: a save made before packages, a revision that a create, copy, or migration published, or a live revision whose build record has expired. The build behind a revision that is not live yet is kept until a later save or publish."
},
"capabilities": {
"additionalProperties": false,
"description": "Capability declarations parsed from the app manifest.",
"properties": {
"connectOrigins": {
"description": "Exact https and wss origins injected into the app CSP connect-src so browser fetch, WebSocket, and EventSource can reach them (e.g. [\"https://api.example.com\", \"wss://stream.example.com\"]). Omitted when the app declares none.",
"items": {
"type": "string"
},
"type": "array"
},
"exports": {
"description": "WIT-style capability ids the app exposes for cross-app calls.",
"items": {
"type": "string"
},
"type": "array"
},
"frameHosts": {
"description": "External https origins the app may embed, added to the app CSP frame-src (e.g. [\"https://www.youtube.com\"]). Omitted when the app declares none.",
"items": {
"type": "string"
},
"type": "array"
},
"imageHosts": {
"description": "External https image hosts injected into the app CSP img-src (e.g. [\"covers.openlibrary.org\"]). Omitted when the app declares none.",
"items": {
"type": "string"
},
"type": "array"
},
"imports": {
"description": "WIT-style capability ids the app requests (e.g. \"charming:storage/[email protected]\"). Empty if the app declares none.",
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"imports",
"exports"
],
"type": "object"
},
"chunk": {
"additionalProperties": false,
"description": "Present only when `bucket` was requested.",
"properties": {
"bucket": {
"description": "The bucket this chunk was read from.",
"enum": [
"module",
"ui",
"styles"
],
"type": "string"
},
"next_offset": {
"anyOf": [
{
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer"
},
{
"type": "null"
}
],
"description": "Offset for the next read of this bucket. Null when this chunk reaches the end."
},
"offset": {
"description": "Character offset where this chunk starts.",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer"
},
"text": {
"description": "Up to 20000 characters of the bucket, ending on a line boundary when the window holds one. Empty for an absent bucket.",
"type": "string"
}
},
"required": [
"bucket",
"offset",
"text",
"next_offset"
],
"type": "object"
},
"claimed": {
"description": "True if the app is owned by an authenticated account. False for anonymous apps still in the unclaimed grace window.",
"type": "boolean"
},
"codeAdvisories": {
"description": "Suggested improvements to the App's server code: the same list the text result shows under \"Suggested improvements\", at most 5, warnings first. Present only when there is something to suggest, and only for a caller who can read the App's source. Apply them together in one update_app call.",
"items": {
"additionalProperties": false,
"properties": {
"fix": {
"description": "What to change, in one line.",
"type": "string"
},
"id": {
"description": "Stable rule id.",
"enum": [
"storage-per-key-reads",
"repeated-full-load",
"sequential-fetch-loop",
"module-near-cap",
"routine-near-limit"
],
"type": "string"
},
"locations": {
"description": "Where in the source it happens. Empty when it is about the App as a whole.",
"items": {
"additionalProperties": false,
"properties": {
"file": {
"description": "Package file path, such as `server.js`, or `module` for an App saved before packages.",
"type": "string"
},
"line": {
"description": "1-based line in that file.",
"exclusiveMinimum": 0,
"maximum": 9007199254740991,
"type": "integer"
}
},
"required": [
"file",
"line"
],
"type": "object"
},
"type": "array"
},
"severity": {
"description": "`warn` slows or breaks the App; `info` is worth a look.",
"enum": [
"info",
"warn"
],
"type": "string"
},
"title": {
"description": "What the code does, in one line.",
"type": "string"
},
"why": {
"description": "Why it matters, in one line.",
"type": "string"
}
},
"required": [
"id",
"severity",
"title",
"locations",
"why",
"fix"
],
"type": "object"
},
"type": "array"
},
"description": {
"description": "Search-friendly summary set by the creating agent. Null on apps created before descriptions existed.",
"type": [
"string",
"null"
]
},
"displayName": {
"description": "Human-readable name from the manifest.",
"type": "string"
},
"expiresAt": {
"description": "ISO timestamp when an unclaimed app will be hard-deleted. Null for claimed apps.",
"type": [
"string",
"null"
]
},
"id": {
"description": "UUID of the inspected app.",
"type": "string"
},
"manifestId": {
"description": "Effective manifest id. May differ from `sourceManifestId` when a conflicting id was rewritten on save.",
"type": "string"
},
"manifestVersion": {
"description": "Deprecated public contract marker. Canonical apps return null; legacy apps return their stored contract date.",
"type": [
"string",
"null"
]
},
"ok": {
"const": true,
"description": "Indicates success. Errors arrive as content with isError:true.",
"type": "boolean"
},
"publication": {
"description": "Whether `revision` is what visitors are served. `published`: it is the active revision. `pending`: its build is still running, so wait for it; or a newer save superseded it, so read the source again. `unpublished`: Charming holds this save without a runnable build, and `activeRevision` keeps serving until a later save publishes. That is a state the App can stay in, not an outage: read `build.error` for the stage and file position that failed, fix the source and save again, or restore the active revision. When `build` is null Charming has no build on record for this save; save it again to build it.",
"enum": [
"published",
"pending",
"unpublished"
],
"type": "string"
},
"revision": {
"description": "The latest saved revision: the source returned here. Pass it as `expected_revision` to update_app. A save is stored before it goes live, so this can be ahead of `activeRevision`.",
"maximum": 9007199254740991,
"minimum": 0,
"type": "integer"
},
"source": {
"additionalProperties": false,
"description": "Persisted source bundle. The same fields accepted by create_app/update_app. Present unless `bucket` was requested; a bucket read returns `chunk` instead.",
"properties": {
"files": {
"additionalProperties": {
"type": "string"
},
"description": "The authored tree of a package App: package.json, server.js, and every file they import. module, ui, and styles mirror server.js, ui.js, and styles.css.",
"propertyNames": {
"type": "string"
},
"type": "object"
},
"module": {
"description": "Backend ES module source.",
"type": "string"
},
"styles": {
"description": "Optional CSS for the rendered app. Null if not set.",
"type": [
"string",
"null"
]
},
"ui": {
"description": "Frontend JavaScript rendered into the #app mount point. Null if not set.",
"type": [
"string",
"null"
]
}
},
"required": [
"module",
"ui",
"styles"
],
"type": "object"
},
"sourceManifestId": {
"description": "Manifest id as authored in the persisted module source.",
"type": "string"
},
"sourceSize": {
"additionalProperties": false,
"description": "Length of each source bucket in characters.",
"properties": {
"module": {
"description": "Characters in the module.",
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer"
},
"styles": {
"anyOf": [
{
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer"
},
{
"type": "null"
}
],
"description": "Characters in the styles. Null if not set."
},
"ui": {
"anyOf": [
{
"maximum": 9007199254740991,
"minimum": -9007199254740991,
"type": "integer"
},
{
"type": "null"
}
],
"description": "Characters in the ui script. Null if not set."
}
},
"required": [
"module",
"ui",
"styles"
],
"type": "object"
},
"url": {
"description": "Public app URL without an access token, built from the OWNER's handle when available (friendly form) and the UUID form otherwise. Safe to show the user. Browsers open via session cookie; agents should call get_app to mint a per-app token for write access.",
"type": "string"
}
},
"required": [
"ok",
"id",
"url",
"manifestId",
"sourceManifestId",
"displayName",
"description",
"revision",
"activeRevision",
"build",
"publication",
"appVersion",
"manifestVersion",
"capabilities",
"claimed",
"expiresAt",
"sourceSize"
],
"type": "object"
}
}