MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / editArtifact

Function editArtifact

packages/hosts/mcp/src/tool-server.ts:1957–1989  ·  view source on GitHub ↗
(input: {
      readonly artifactId: string;
      readonly edits: readonly ArtifactEdit[];
      readonly title?: string;
      readonly description?: string;
      readonly connections?: Readonly<Record<string, string>>;
    })

Source from the content-addressed store, hash-verified

1955 * back here makes the retry immediate.
1956 */
1957 const editArtifact = (input: {
1958 readonly artifactId: string;
1959 readonly edits: readonly ArtifactEdit[];
1960 readonly title?: string;
1961 readonly description?: string;
1962 readonly connections?: Readonly<Record<string, string>>;
1963 }): Effect.Effect<McpToolResult, unknown> =>
1964 Effect.gen(function* () {
1965 // Same probe-proof refusal as create-artifact's update arm.
1966 const existing = yield* loadArtifact(input.artifactId);
1967 if (!existing) return actionArtifactUnavailableResult();
1968
1969 const applied = applyArtifactEdits(existing.code, input.edits);
1970 if (!applied.ok) return editRejectedResult(applied.message, existing.code);
1971
1972 yield* Effect.annotateCurrentSpan({
1973 "mcp.artifact.edit_count": input.edits.length,
1974 });
1975 return yield* validateRenderAndSave({
1976 code: applied.code,
1977 title: input.title ?? existing.title,
1978 description: input.description ?? existing.description ?? undefined,
1979 connections: input.connections,
1980 existing,
1981 });
1982 }).pipe(
1983 Effect.withSpan("mcp.host.tool.edit_artifact", {
1984 attributes: {
1985 "mcp.tool.name": "edit-artifact",
1986 "mcp.artifact.id": input.artifactId,
1987 },
1988 }),
1989 );
1990
1991 const listArtifacts = (): Effect.Effect<McpToolResult, unknown> =>
1992 Effect.gen(function* () {

Callers 1

createExecutorMcpServerFunction · 0.85

Calls 5

applyArtifactEditsFunction · 0.90
loadArtifactFunction · 0.85
editRejectedResultFunction · 0.85
validateRenderAndSaveFunction · 0.85

Tested by

no test coverage detected