Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(mcp): create skill versions and manage labels and tags (#19247)

tobi_kl8e60314ce6e1
diff --git a/packages/shared/src/in-app-agent/server/mcpPolicy.ts b/packages/shared/src/in-app-agent/server/mcpPolicy.ts
index 3aba9a790d..7e70d3fd16 100644
--- a/packages/shared/src/in-app-agent/server/mcpPolicy.ts
+++ b/packages/shared/src/in-app-agent/server/mcpPolicy.ts
@@ -325,6 +325,18 @@ export const IN_APP_AGENT_LANGFUSE_MCP_TOOL_POLICIES = {
approval: "auto",
availability: { scope: "skills:read" },
},
+ createSkillVersion: {
+ approval: "approval",
+ availability: { scope: "skills:CUD" },
+ },
+ updateSkillLabels: {
+ approval: "approval",
+ availability: { scope: "skills:CUD" },
+ },
+ updateSkillTags: {
+ approval: "approval",
+ availability: { scope: "skills:CUD" },
+ },
listScores: {
approval: "auto",
availability: { scope: "project:read" },
diff --git a/web/src/__tests__/server/mcp-public-api-tools.servertest.ts b/web/src/__tests__/server/mcp-public-api-tools.servertest.ts
index 65fd220427..b8b566233f 100644
--- a/web/src/__tests__/server/mcp-public-api-tools.servertest.ts
+++ b/web/src/__tests__/server/mcp-public-api-tools.servertest.ts
@@ -262,6 +262,7 @@ describe("MCP public API tools", () => {
"createEvaluator",
"createScore",
"createScoreConfig",
+ "createSkillVersion",
"createTextPrompt",
"deleteAnnotationQueueAssignment",
"deleteAnnotationQueueItem",
@@ -283,6 +284,8 @@ describe("MCP public API tools", () => {
"updateEvaluator",
"updatePromptLabels",
"updateScoreConfig",
+ "updateSkillLabels",
+ "updateSkillTags",
"upsertDataset",
"upsertDatasetItem",
].sort(),
diff --git a/web/src/__tests__/server/mcp-tools-write.servertest.ts b/web/src/__tests__/server/mcp-tools-write.servertest.ts
index 0e20be8855..ba543c7643 100644
--- a/web/src/__tests__/server/mcp-tools-write.servertest.ts
+++ b/web/src/__tests__/server/mcp-tools-write.servertest.ts
@@ -45,6 +45,13 @@ import { prisma, Role } from "@langfuse/shared/src/db";
import { nanoid } from "nanoid";
import { z } from "zod";
import { ErrorCode } from "@modelcontextprotocol/sdk/types.js";
+import { SkillVersionSchema } from "@langfuse/shared";
+import { handleUpdateSkillLabels } from "@/src/features/mcp/server/skills/tools/updateSkillLabels";
+import { handleUpdateSkillTags } from "@/src/features/mcp/server/skills/tools/updateSkillTags";
+import { handleGetSkill } from "@/src/features/mcp/server/skills/tools/getSkill";
+import { handleCreateSkillVersion } from "@/src/features/mcp/server/skills/tools/createSkillVersion";
+import { handleLoadSkill } from "@/src/features/mcp/server/skills/tools/loadSkill";
+import { handleLoadSkillResource } from "@/src/features/mcp/server/skills/tools/loadSkillResource";
import {
createInAppAgentMcpContext,
createMcpTestSetup,
@@ -188,6 +195,263 @@ const createLlmEvaluationRuleForMcpWriteTest = async (
};
describe("MCP Write Tools", () => {
+ describe("skill metadata", () => {
+ const createVersion = async (
+ setup: Awaited<ReturnType<typeof createMcpTestSetup>>,
+ name: string,
+ ) =>
+ SkillVersionSchema.parse(
+ await handleCreateSkillVersion(
+ {
+ files: [
+ {
+ path: "SKILL.md",
+ content: `---\nname: ${name}\ndescription: Metadata test\n---\nInstructions.`,
+ },
+ ],
+ },
+ setup.context,
+ ),
+ );
+
+ it("replaces tags across versions with audit logging and project isolation", async () => {
+ const setup = await createMcpTestSetup();
+ const name = `tags-${nanoid().toLowerCase().replace(/[_-]/g, "a")}`;
+ await createVersion(setup, name);
+ await handleUpdateSkillLabels(
+ { name, version: 1, labels: ["production"] },
+ setup.context,
+ );
+ const second = await createVersion(setup, name);
+
+ await expect(
+ handleUpdateSkillTags(
+ { name, tags: [" support ", "support"] },
+ setup.context,
+ ),
+ ).resolves.toMatchObject({
+ id: second.id,
+ version: 2,
+ tags: ["support"],
+ labels: ["latest"],
+ });
+ await expect(
+ handleGetSkill({ name, version: 1 }, setup.context),
+ ).resolves.toMatchObject({ tags: ["support"], labels: ["production"] });
+ expect(
+ await prisma.auditLog.findFirst({
+ where: {
+ projectId: setup.projectId,
+ apiKeyId: setup.apiKeyId,
+ resourceType: "skill",
+ resourceId: name,
+ action: "setTag",
+ after: JSON.stringify(["support"]),
+ },
+ }),
+ ).not.toBeNull();
+
+ const otherProject = await createMcpTestSetup();
+ await expect(
+ handleUpdateSkillTags({ name, tags: ["other"] }, otherProject.context),
+ ).rejects.toThrow("Skill not found");
+ await expect(
+ handleUpdateSkillTags({ name, tags: [" "] }, setup.context),
+ ).rejects.toThrow();
+ await expect(
+ handleGetSkill({ name, version: 2 }, setup.context),
+ ).resolves.toMatchObject({ tags: ["support"] });
+
+ await handleUpdateSkillTags({ name, tags: [] }, setup.context);
+ for (const version of [1, 2]) {
+ await expect(
+ handleGetSkill({ name, version }, setup.context),
+ ).resolves.toMatchObject({ tags: [] });
+ }
+ expect(
+ await prisma.skill.count({
+ where: { projectId: setup.projectId, name },
+ }),
+ ).toBe(2);
+ });
+
+ it("moves production, replaces user labels, preserves latest, and audits changes", async () => {
+ const setup = await createMcpTestSetup();
+ const name = `labels-${nanoid().toLowerCase().replace(/[_-]/g, "a")}`;
+ const first = await createVersion(setup, name);
+ await handleUpdateSkillLabels(
+ { name, version: 1, labels: ["production"] },
+ setup.context,
+ );
+ const second = await createVersion(setup, name);
+ await handleUpdateSkillLabels(
+ { name, version: 2, labels: ["staging"] },
+ setup.context,
+ );
+
+ await expect(
+ handleUpdateSkillLabels(
+ { name, version: 2, labels: ["production"] },
+ setup.context,
+ ),
+ ).resolves.toMatchObject({
+ id: second.id,
+ labels: ["production", "latest"],
+ });
+ await expect(
+ handleGetSkill({ name, label: "production" }, setup.context),
+ ).resolves.toMatchObject({ version: 2 });
+ await expect(
+ handleGetSkill({ name, version: 1 }, setup.context),
+ ).resolves.toMatchObject({ labels: [] });
+ for (const [id, before, after] of [
+ [first.id, ["production"], []],
+ [second.id, ["staging", "latest"], ["production", "latest"]],
+ ] as const) {
+ expect(
+ await prisma.auditLog.findFirst({
+ where: {
+ projectId: setup.projectId,
+ apiKeyId: setup.apiKeyId,
+ resourceId: id,
+ resourceType: "skill",
+ action: "setLabel",
+ before: JSON.stringify(before),
+ after: JSON.stringify(after),
+ },
+ }),
+ ).not.toBeNull();
+ }
+ await expect(
+ handleUpdateSkillLabels(
+ { name, version: 2, labels: [] },
+ setup.context,
+ ),
+ ).resolves.toMatchObject({ labels: ["latest"] });
+ await expect(
+ handleUpdateSkillLabels(
+ { name, version: 2, labels: ["latest"] },
+ setup.context,
+ ),
+ ).rejects.toThrow("managed by Langfuse");
+
+ const otherProject = await createMcpTestSetup();
+ await expect(
+ handleUpdateSkillLabels(
+ { name, version: 2, labels: ["production"] },
+ otherProject.context,
+ ),
+ ).rejects.toThrow("Skill version not found");
+ });
+
+ it.each([Role.MEMBER, Role.ADMIN])(
+ "respects protected production labels for Halo role %s",
+ async (role) => {
+ const setup = await createMcpTestSetup();
+ const name = `protected-${nanoid().toLowerCase().replace(/[_-]/g, "a")}`;
+ await createVersion(setup, name);
+ await protectPromptLabel({
+ projectId: setup.projectId,
+ label: "production",
+ });
+ const { userId } = await createUserWithOrgRole({
+ orgId: setup.orgId,
+ role,
+ });
+ const { context } = await createInAppAgentMcpContext({
+ projectId: setup.projectId,
+ orgId: setup.orgId,
+ createdByUserId: userId,
+ });
+ const update = handleUpdateSkillLabels(
+ { name, version: 1, labels: ["production"] },
+ context,
+ );
+ if (role === Role.MEMBER) {
+ await expect(update).rejects.toThrow(
+ "permission to mutate protected skill labels",
+ );
+ await expect(
+ handleGetSkill({ name, version: 1 }, setup.context),
+ ).resolves.toMatchObject({ labels: ["latest"] });
+ } else {
+ await expect(update).resolves.toMatchObject({
+ labels: ["production", "latest"],
+ });
+ }
+ },
+ );
+ });
+
+ describe("skill creation", () => {
+ it("persists audited skill versions and preserves earlier file contents", async () => {
+ const setup = await createMcpTestSetup();
+ const name = `mcp-skill-${nanoid().toLowerCase().replace(/[_-]/g, "a")}`;
+ const markdown = `---\nname: ${name}\ndescription: A test skill\n---\nUse the reference.`;
+ const input = {
+ files: [
+ { path: "SKILL.md", content: markdown },
+ { path: "references/example.md", content: "First reference" },
+ ],
+ commitMessage: "Initial version",
+ };
+
+ const first = SkillVersionSchema.parse(
+ await handleCreateSkillVersion(input, setup.context),
+ );
+ expect(first).toMatchObject({
+ name,
+ description: "A test skill",
+ projectId: setup.projectId,
+ version: 1,
+ labels: ["latest"],
+ commitMessage: input.commitMessage,
+ });
+ await verifyAuditLog({
+ projectId: setup.projectId,
+ apiKeyId: setup.apiKeyId,
+ resourceType: "skill",
+ resourceId: first.id,
+ action: "create",
+ });
+
+ const second = SkillVersionSchema.parse(
+ await handleCreateSkillVersion(
+ { files: [{ path: "SKILL.md", content: `${markdown}\nUpdated.` }] },
+ setup.context,
+ ),
+ );
+ expect(second).toMatchObject({ name, version: 2, labels: ["latest"] });
+ await expect(
+ handleLoadSkill({ name, version: 1 }, setup.context),
+ ).resolves.toBe(markdown);
+ await expect(
+ handleLoadSkill({ name, version: 2 }, setup.context),
+ ).resolves.toBe(`${markdown}\nUpdated.`);
+ await expect(
+ handleLoadSkillResource(
+ { name, version: 1, path: "references/example.md" },
+ setup.context,
+ ),
+ ).resolves.toBe("First reference");
+ });
+
+ it("rejects invalid skill files before persisting a version", async () => {
+ const setup = await createMcpTestSetup();
+ await expect(
+ handleCreateSkillVersion(
+ { files: [{ path: "reference.md", content: "Missing root file" }] },
+ setup.context,
+ ),
+ ).rejects.toThrow(
+ "Every skill version must contain a root SKILL.md file",
+ );
+ expect(
+ await prisma.skill.count({ where: { projectId: setup.projectId } }),
+ ).toBe(0);
+ });
+ });
+
describe("dataset tool schemas", () => {
it("uses dataset IDs for existing dataset write addressing", () => {
for (const schema of [
diff --git a/web/src/__tests__/server/unit/in-app-agent-mcp-policy.servertest.ts b/web/src/__tests__/server/unit/in-app-agent-mcp-policy.servertest.ts
index 4b6eebbe30..ba308aec04 100644
--- a/web/src/__tests__/server/unit/in-app-agent-mcp-policy.servertest.ts
+++ b/web/src/__tests__/server/unit/in-app-agent-mcp-policy.servertest.ts
@@ -2,6 +2,7 @@ import { describe, expect, expectTypeOf, it } from "vitest";
import {
createInAppAgentToolPolicy,
+ getInAppAgentMcpAllowedToolNames,
IN_APP_AGENT_LANGFUSE_MCP_TOOL_POLICIES,
type InAppAgentLangfuseMcpToolName,
} from "@langfuse/shared/in-app-agent/server/mcpPolicy";
@@ -17,7 +18,9 @@ describe("IN_APP_AGENT_LANGFUSE_MCP_TOOL_POLICIES", () => {
const policy = createInAppAgentToolPolicy({
userAccess: { projectRole: "VIEWER", isAdmin: false },
});
- for (const { definition } of skillsFeature.tools) {
+ for (const { definition } of skillsFeature.tools.filter(
+ ({ definition }) => definition.annotations?.readOnlyHint === true,
+ )) {
expect(toolRegistry.getTool(definition.name)?.definition).toEqual(
definition,
);
@@ -28,6 +31,42 @@ describe("IN_APP_AGENT_LANGFUSE_MCP_TOOL_POLICIES", () => {
}
});
+ it.each(["createSkillVersion", "updateSkillLabels", "updateSkillTags"])(
+ "requires approval for %s and excludes viewers even with a stored grant",
+ (toolName) => {
+ const memberPolicy = createInAppAgentToolPolicy({
+ userAccess: { projectRole: "MEMBER", isAdmin: false },
+ });
+ expect([...memberPolicy.available]).toContain(toolName);
+ expect([...memberPolicy.autoApproved]).not.toContain(toolName);
+ expect(getInAppAgentMcpAllowedToolNames(memberPolicy)).not.toContain(
+ toolName,
+ );
+
+ const grantedMemberPolicy = createInAppAgentToolPolicy({
+ userAccess: { projectRole: "MEMBER", isAdmin: false },
+ alwaysAllowedTools: [`langfuse_${toolName}`],
+ });
+ expect(getInAppAgentMcpAllowedToolNames(grantedMemberPolicy)).toContain(
+ toolName,
+ );
+
+ const viewerPolicy = createInAppAgentToolPolicy({
+ userAccess: { projectRole: "VIEWER", isAdmin: false },
+ alwaysAllowedTools: [`langfuse_${toolName}`],
+ });
+ expect([...viewerPolicy.available]).not.toContain(toolName);
+ expect([...viewerPolicy.autoApproved]).not.toContain(toolName);
+ expect(getInAppAgentMcpAllowedToolNames(viewerPolicy)).not.toContain(
+ toolName,
+ );
+ const definition = toolRegistry.getTool(toolName)?.definition;
+ expect(definition?.action).toBe("skills:CUD");
+ expect(definition?.annotations?.destructiveHint).toBe(true);
+ expect(definition?.annotations?.readOnlyHint).not.toBe(true);
+ },
+ );
+
it("does not expose Skills MCP tools without user access", () => {
const policy = createInAppAgentToolPolicy({});
for (const { definition } of skillsFeature.tools) {
diff --git a/web/src/features/in-app-agent/components/utils/side-effects.clienttest.ts b/web/src/features/in-app-agent/components/utils/side-effects.clienttest.ts
new file mode 100644
index 0000000000..8abc6e48fa
--- /dev/null
+++ b/web/src/features/in-app-agent/components/utils/side-effects.clienttest.ts
@@ -0,0 +1,51 @@
+import { IN_APP_AGENT_TOOL_REJECTION_ERROR_CODE } from "@langfuse/shared/in-app-agent";
+import { performToolSideEffectsForCompletedToolCalls } from "./side-effects";
+
+function createUtils() {
+ const invalidate = vi.fn().mockResolvedValue(undefined);
+ const utils = { skills: { invalidate } } as unknown as Parameters<
+ typeof performToolSideEffectsForCompletedToolCalls
+ >[0]["utils"];
+ return { utils, invalidate };
+}
+
+describe("skill tool side effects", () => {
+ it("invalidates skills for approved skill write tools", async () => {
+ const { utils, invalidate } = createUtils();
+ const handledToolCallIds = new Set<string>();
+
+ for (const toolName of [
+ "langfuse_createSkillVersion",
+ "langfuse_updateSkillLabels",
+ "langfuse_updateSkillTags",
+ ]) {
+ await performToolSideEffectsForCompletedToolCalls({
+ toolCalls: [{ toolCallId: toolName, toolName }],
+ handledToolCallIds,
+ utils,
+ });
+ }
+
+ expect(invalidate).toHaveBeenCalledTimes(3);
+ });
+
+ it("does not invalidate skills for a rejected call", async () => {
+ const { utils, invalidate } = createUtils();
+
+ await performToolSideEffectsForCompletedToolCalls({
+ toolCalls: [
+ {
+ toolCallId: "rejected-label-update",
+ toolName: "langfuse_updateSkillLabels",
+ toolError: JSON.stringify({
+ code: IN_APP_AGENT_TOOL_REJECTION_ERROR_CODE,
+ }),
+ },
+ ],
+ handledToolCallIds: new Set(),
+ utils,
+ });
+
+ expect(invalidate).not.toHaveBeenCalled();
+ });
+});
diff --git a/web/src/features/in-app-agent/components/utils/side-effects.ts b/web/src/features/in-app-agent/components/utils/side-effects.ts
index 824822c860..bcd61308c1 100644
--- a/web/src/features/in-app-agent/components/utils/side-effects.ts
+++ b/web/src/features/in-app-agent/components/utils/side-effects.ts
@@ -23,7 +23,8 @@ export type InAppAgentTrpcInvalidationTarget =
| "prompts"
| "scoreAnalytics"
| "scoreConfigs"
- | "scores";
+ | "scores"
+ | "skills";
type InAppAgentMcpToolName = `langfuse_${InAppAgentLangfuseMcpToolName}`;
@@ -117,6 +118,9 @@ const IN_APP_AGENT_TOOL_TRPC_INVALIDATION_TARGETS = {
langfuse_getSkill: [],
langfuse_loadSkill: [],
langfuse_loadSkillResource: [],
+ langfuse_createSkillVersion: ["skills"],
+ langfuse_updateSkillLabels: ["skills"],
+ langfuse_updateSkillTags: ["skills"],
langfuse_listScores: [],
langfuse_getScore: [],
langfuse_createScore: ["scores", "scoreAnalytics"],
@@ -215,6 +219,9 @@ function performTargetInvalidation(
if (target === "scores") {
return utils.scores.invalidate();
}
+ if (target === "skills") {
+ return utils.skills.invalidate();
+ }
return assertUnreachable(target);
}
diff --git a/web/src/features/in-app-agent/components/utils/utils.ts b/web/src/features/in-app-agent/components/utils/utils.ts
index 294e7af952..e748b30183 100644
--- a/web/src/features/in-app-agent/components/utils/utils.ts
+++ b/web/src/features/in-app-agent/components/utils/utils.ts
@@ -76,6 +76,9 @@ const IN_APP_AGENT_TOOL_PROGRESS_LABEL_OVERRIDES: Record<string, string> = {
getPromptUnresolved: "Inspecting prompt",
getRequestContext: "Checking request context",
getSkill: "Inspecting skill",
+ createSkillVersion: "Creating skill version",
+ updateSkillLabels: "Updating skill labels",
+ updateSkillTags: "Updating skill tags",
listDashboardWidgets: "Browsing widgets",
listLlmConnections: "Browsing LLM connections",
listSkills: "Browsing skills",
diff --git a/web/src/features/mcp/server/skills/index.ts b/web/src/features/mcp/server/skills/index.ts
index f4cd61a8d2..debfc220f3 100644
--- a/web/src/features/mcp/server/skills/index.ts
+++ b/web/src/features/mcp/server/skills/index.ts
@@ -1,7 +1,19 @@
import type { McpFeatureModule } from "../registry";
+import {
+ createSkillVersionTool,
+ handleCreateSkillVersion,
+} from "./tools/createSkillVersion";
import { getSkillTool, handleGetSkill } from "./tools/getSkill";
import { listSkillsTool, handleListSkills } from "./tools/listSkills";
import { loadSkillTool, handleLoadSkill } from "./tools/loadSkill";
+import {
+ updateSkillLabelsTool,
+ handleUpdateSkillLabels,
+} from "./tools/updateSkillLabels";
+import {
+ updateSkillTagsTool,
+ handleUpdateSkillTags,
+} from "./tools/updateSkillTags";
import {
loadSkillResourceTool,
handleLoadSkillResource,
@@ -10,11 +22,14 @@ import {
export const skillsFeature = {
name: "skills",
description:
- "List skills, retrieve version manifests, and load text resources",
+ "Create skill versions, update labels and tags, list skills, retrieve manifests, and load text resources",
tools: [
{ definition: listSkillsTool, handler: handleListSkills },
{ definition: getSkillTool, handler: handleGetSkill },
{ definition: loadSkillTool, handler: handleLoadSkill },
{ definition: loadSkillResourceTool, handler: handleLoadSkillResource },
+ { definition: createSkillVersionTool, handler: handleCreateSkillVersion },
+ { definition: updateSkillLabelsTool, handler: handleUpdateSkillLabels },
+ { definition: updateSkillTagsTool, handler: handleUpdateSkillTags },
],
} as const satisfies McpFeatureModule;
diff --git a/web/src/features/mcp/server/skills/tools/createSkillVersion.ts b/web/src/features/mcp/server/skills/tools/createSkillVersion.ts
new file mode 100644
index 0000000000..2a27fdaa5a
--- /dev/null
+++ b/web/src/features/mcp/server/skills/tools/createSkillVersion.ts
@@ -0,0 +1,66 @@
+import { z } from "zod";
+import {
+ COMMIT_MESSAGE_MAX_LENGTH,
+ CreateSkillVersionBodySchema,
+ MAX_SKILL_FILES,
+ SkillFilePathSchema,
+ SkillVersionFileInputSchema,
+} from "@langfuse/shared";
+import { prisma } from "@langfuse/shared/src/db";
+import { SkillService } from "@/src/features/skills/server";
+import { defineTool } from "../../../core/define-tool";
+import { runMcpTool } from "../../../core/run-mcp-tool";
+
+const CreateSkillVersionBaseSchema = z.object({
+ files: z
+ .array(
+ z.object({
+ path: SkillFilePathSchema,
+ content: z.string().describe("Full UTF-8 text content of the file"),
+ }),
+ )
+ .min(1)
+ .max(MAX_SKILL_FILES)
+ .describe(
+ "Complete set of files for this version, including a root SKILL.md with YAML name and description frontmatter. Maximum 1 MB of text in total.",
+ ),
+ commitMessage: z
+ .string()
+ .max(COMMIT_MESSAGE_MAX_LENGTH)
+ .optional()
+ .describe("Optional description of the changes"),
+});
+
+export const [createSkillVersionTool, handleCreateSkillVersion] = defineTool({
+ name: "createSkillVersion",
+ description: [
+ "Create a skill or a new immutable version of an existing skill in the current project.",
+ "Provide all files as inline text, including SKILL.md with YAML frontmatter containing name and description.",
+ "The name identifies the skill; using an existing name creates its next version. Omitted files are absent from the new version, while earlier versions remain unchanged.",
+ "New versions receive the latest label; this does not promote them to production or install them into Halo's own instructions.",
+ ].join(" "),
+ action: "skills:CUD",
+ baseSchema: CreateSkillVersionBaseSchema,
+ inputSchema: CreateSkillVersionBodySchema.safeExtend({
+ files: z.array(SkillVersionFileInputSchema).min(1).max(MAX_SKILL_FILES),
+ }),
+ handler: (input, context) =>
+ runMcpTool({
+ spanName: "mcp.skills.createVersion",
+ context,
+ fn: async () =>
+ new SkillService(prisma).createVersion({
+ projectId: context.projectId,
+ createdBy: context.userId ?? "API",
+ input,
+ actor: {
+ apiKeyId: context.apiKeyId,
+ orgId: context.orgId,
+ projectId: context.projectId,
+ accessLevel: context.accessLevel,
+ ctx: context.auth,
+ },
+ }),
+ }),
+ destructiveHint: true,
+});
diff --git a/web/src/features/mcp/server/skills/tools/updateSkillLabels.ts b/web/src/features/mcp/server/skills/tools/updateSkillLabels.ts
new file mode 100644
index 0000000000..7f8239fc61
--- /dev/null
+++ b/web/src/features/mcp/server/skills/tools/updateSkillLabels.ts
@@ -0,0 +1,44 @@
+import { z } from "zod";
+import { SkillNameSchema, UpdateSkillLabelsBodySchema } from "@langfuse/shared";
+import { prisma } from "@langfuse/shared/src/db";
+import { SkillService } from "@/src/features/skills/server";
+import { defineTool } from "../../../core/define-tool";
+import { runMcpTool } from "../../../core/run-mcp-tool";
+
+const UpdateSkillLabelsSchema = UpdateSkillLabelsBodySchema.extend({
+ name: SkillNameSchema,
+ version: z.number().int().positive(),
+});
+
+export const [updateSkillLabelsTool, handleUpdateSkillLabels] = defineTool({
+ name: "updateSkillLabels",
+ description: [
+ "Replace the user-managed labels on a specific skill version in the current project.",
+ "Include every label to retain; an empty labels array removes all user-managed labels from that version.",
+ "Labels are unique across versions of a skill: assigning a label moves it from any other version.",
+ "The latest label is automatically managed, is preserved, and must not be supplied.",
+ "Only assign the production label when the user explicitly asks to promote that version. Read its current labels first and include any labels the user wants to retain.",
+ "Protected-label permissions apply to both adding and removing labels, even after approval.",
+ ].join(" "),
+ action: "skills:CUD",
+ baseSchema: UpdateSkillLabelsSchema,
+ inputSchema: UpdateSkillLabelsSchema,
+ handler: (input, context) =>
+ runMcpTool({
+ spanName: "mcp.skills.updateLabels",
+ context,
+ fn: async () =>
+ new SkillService(prisma).setLabels({
+ ...input,
+ projectId: context.projectId,
+ actor: {
+ apiKeyId: context.apiKeyId,
+ orgId: context.orgId,
+ projectId: context.projectId,
+ accessLevel: context.accessLevel,
+ ctx: context.auth,
+ },
+ }),
+ }),
+ destructiveHint: true,
+});
diff --git a/web/src/features/mcp/server/skills/tools/updateSkillTags.ts b/web/src/features/mcp/server/skills/tools/updateSkillTags.ts
new file mode 100644
index 0000000000..a82008780a
--- /dev/null
+++ b/web/src/features/mcp/server/skills/tools/updateSkillTags.ts
@@ -0,0 +1,40 @@
+import { SkillNameSchema, UpdateSkillTagsBodySchema } from "@langfuse/shared";
+import { prisma } from "@langfuse/shared/src/db";
+import { SkillService } from "@/src/features/skills/server";
+import { defineTool } from "../../../core/define-tool";
+import { runMcpTool } from "../../../core/run-mcp-tool";
+
+const UpdateSkillTagsSchema = UpdateSkillTagsBodySchema.extend({
+ name: SkillNameSchema,
+});
+
+export const [updateSkillTagsTool, handleUpdateSkillTags] = defineTool({
+ name: "updateSkillTags",
+ description: [
+ "Replace the tags on a skill in the current project, across all of its versions.",
+ "Read the current tags first and include every tag to retain; an empty tags array removes all tags.",
+ "This does not create a version or change version labels. Returns the latest version's metadata.",
+ "Adding or removing discovery tags can change which skills integrations, including Halo, load.",
+ ].join(" "),
+ action: "skills:CUD",
+ baseSchema: UpdateSkillTagsSchema,
+ inputSchema: UpdateSkillTagsSchema,
+ handler: (input, context) =>
+ runMcpTool({
+ spanName: "mcp.skills.updateTags",
+ context,
+ fn: async () =>
+ new SkillService(prisma).setTags({
+ ...input,
+ projectId: context.projectId,
+ actor: {
+ apiKeyId: context.apiKeyId,
+ orgId: context.orgId,
+ projectId: context.projectId,
+ accessLevel: context.accessLevel,
+ ctx: context.auth,
+ },
+ }),
+ }),
+ destructiveHint: true,
+});