Browse Source

fix: display MCP tag for prompts in autocomplete but not in prompt (#6531)

Paolo Ricciuti 1 month ago
parent
commit
5249f04ea0

+ 1 - 1
packages/opencode/src/cli/cmd/tui/component/prompt/autocomplete.tsx

@@ -259,7 +259,7 @@ export function Autocomplete(props: {
     const s = session()
     for (const command of sync.data.command) {
       results.push({
-        display: "/" + command.name,
+        display: "/" + command.name + (command.mcp ? " (MCP)" : ""),
         description: command.description,
         onSelect: () => {
           const newText = "/" + command.name + " "

+ 2 - 0
packages/opencode/src/command/index.ts

@@ -27,6 +27,7 @@ export namespace Command {
       description: z.string().optional(),
       agent: z.string().optional(),
       model: z.string().optional(),
+      mcp: z.boolean().optional(),
       // workaround for zod not supporting async functions natively so we use getters
       // https://zod.dev/v4/changelog?id=zfunction
       template: z.promise(z.string()).or(z.string()),
@@ -94,6 +95,7 @@ export namespace Command {
     for (const [name, prompt] of Object.entries(await MCP.prompts())) {
       result[name] = {
         name,
+        mcp: true,
         description: prompt.description,
         get template() {
           // since a getter can't be async we need to manually return a promise here

+ 1 - 1
packages/opencode/src/mcp/index.ts

@@ -195,7 +195,7 @@ export namespace MCP {
     for (const prompt of prompts.prompts) {
       const sanitizedClientName = clientName.replace(/[^a-zA-Z0-9_-]/g, "_")
       const sanitizedPromptName = prompt.name.replace(/[^a-zA-Z0-9_-]/g, "_")
-      const key = sanitizedClientName + ":" + sanitizedPromptName + " (MCP)"
+      const key = sanitizedClientName + ":" + sanitizedPromptName
 
       commands[key] = { ...prompt, client: clientName }
     }

+ 1 - 0
packages/sdk/js/src/v2/gen/types.gen.ts

@@ -1733,6 +1733,7 @@ export type Command = {
   description?: string
   agent?: string
   model?: string
+  mcp?: boolean
   template: string
   subtask?: boolean
   hints: Array<string>

+ 3 - 0
packages/sdk/openapi.json

@@ -8982,6 +8982,9 @@
           "model": {
             "type": "string"
           },
+          "mcp": {
+            "type": "boolean"
+          },
           "template": {
             "anyOf": [
               {