Skip to content

[FEATURE]: Setting global permissions for custom tool #4881

Closed as not planned

Description

@JosXa

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I have written this custom tool:

tool/read-dotenv.ts

import { tool } from "@opencode-ai/plugin"

export default tool({
  description: "Read a .env file given its absolute path",
  args: {
    path: tool.schema.string().describe("Absolute path to the .env file"),
  },
  async execute(args) {
    const content = await Bun.file(args.path).text();
    return content;
  },
})

Now I'm trying to turn it into ask mode in config.json:

  "permission": {
    "read-dotenv": "ask",
  },

This makes no difference, it is always run. Leading me to conclude that setting permissions on custom tools is just not possible right now - please tell me if it is!

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Nov 28, 2025
  2. github-actions commented on Nov 28, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. rekram1-node commented on Dec 5, 2025

    @rekram1-node
    Contributor

    Yeah permissions only apply to a few tools rn we are gonna make them work w/ everything and w/ wildcards

  4. self-assigned this
    on Dec 5, 2025
  5. peltax commented on Mar 8, 2026

    @peltax

    For now you can add the permission check in custom tool itself:

    export default tool({
      description: "Ask a question",
      args: {
        query: tool.schema.string().describe("Search query")
      },
      async execute(args, ctx) {
        const q = encodeURIComponent(args.query);    
        await ctx.ask({
          permission: "mytoolname",
          patterns: [q],
          always: ["*"],
          metadata: {},
        })
       
        // at this point permission is already granted
    
  6. nodiscc commented on Apr 21, 2026

    @nodiscc

    Still reproducible on v1.14.19

    Example working custom tool:

    $ cat ~/.config/opencode/tools/searxng.ts 
    import { tool } from "@opencode-ai/plugin"
    
    const SEARXNG_URL = "https://searx.example.org/search"
    
    export default tool({
      description: "Search the web using self-hosted SearXNG instance",
      args: {
        query: tool.schema.string().describe("Search query"),
        limit: tool.schema.number().optional().describe("Max number of results (default 10)"),
      },
    
        const limit = args.limit || 10
        const url = `${SEARXNG_URL}?q=${encodeURIComponent(args.query)}&format=json`
        const raw = await Bun.$`curl -k -s ${url}`.text()
        const data = JSON.parse(raw)
        const results = (data.results || []).slice(0, limit)
        return JSON.stringify(
          results.map((r) => ({
            title: r.title,
            url: r.url,
            engine: r.engine,
            content: r.content || "",
          })),
          null,
          2,
        )
      },
    })

    The tool always runs without asking for permission, for example when prompted with do a searxng search for "example topic"

    The workaround (adding await ctx.ask) mentioned by @peltax doesn't seem to work either, the tool still runs without asking for permission.

  7. added a commit that references this issue on Apr 30, 2026
    96a7ac1
  8. removed
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on May 3, 2026
  9. added a commit that references this issue on May 20, 2026
    2b6eb74
  10. github-actions commented on Jul 3, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions