Skip to content

Refactor: Tool registry on server #20673

Closed
4 of 5 issues completed
Closed

Description

@ngxson

Background Description

Currently, llama-server has no knowledge about tools or MCP, all the logic is implemented on webui client side. This introduce a lot of duplicated code if we want to also support MCP and tools on llama-cli

The plan is to allow user to use built-in tools and MCP tools from llama-cli by having a mcp.json file

Possible Refactor Approaches

Tool registry will allow having 2 types of tools:

  • Built-in tools, served in OAI-compat schema
  • MCP tools: this will reflect just the server URL, NOT a list of tools from that server. The client will be responsible for extracting tools from this server (on webui, we already had this logic; on CLI, we will need to implement this logic)

For MCP tools, we support both streaming HTTP and stdio protocols, using http://, https:// and stdio:// protocols respectively

Client call POST /tools to effectively "proxy" the request to the destination MCP server/stdio

Example of a list returned from GET /tools:

  • read_file: built-in tool
  • edit_file: built-in tool
  • list_files: built-in tool
  • huggingface-mcp: MCP server
  • python-interpreter: MCP stdio

Sub-issues

Sub-issues

4 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. pwilkin commented on Mar 17, 2026

    @pwilkin
    Member

    Okay, so actually I was thinking of directly listing the tools from MCP servers etc. because that allows us to unify everything behind a single framework. I've been thinking about this quite a bit and this actually eases the implementation of skills since we can add tools like skill:<skillname>:run with the skill script path. Generally using the source:toolname approach is enough to disambiguate and also helps with accidental tool conflicts. Plus this makes the whole tool gathering / tool execution phase much less tedious since the registry basically handles the request and then delegates to the proper handler (MCP / builtin / skill).

  2. ngxson commented on Mar 18, 2026

    @ngxson
    CollaboratorAuthor

    Okay, so actually I was thinking of directly listing the tools from MCP servers etc.

    My initial plan looks somewhat like this, but I doubt if it will require a lot of changes in web UI in the short term.

    Nevertheless, I think the first step could be to implement the C++ MCP client inside the CLI first, then investigate if it's possible for web UI to reuse that later on.

    Re skills, I think it can be done completely separate to MCP stuff. Skill scripts can be exposed as tools, much like built-in tools. Skills and and resources related to skills can be discovered via doing a scan inside an user-defined directory

  3. allozaur commented on Mar 19, 2026

    @allozaur
    Contributor

    I think that from WebUI's perspective we'd simply switch from the MCP Servers selector/enabler dropdown to Tools Selector component and we'd list built-in tools in the same tree as the JSON Schema originating tools as well as MCP originating tools:

    TOOLS
    
    -- Built-in
    ---- read_file
    ---- edit_file
    ---- list_files
    
    -- Hugging Face MCP
    ---- tool_1
    ---- tool_2
    -- Some other MCP
    
    ...
    
    -- JSON Schema
    ---- tool_x
    ---- tool_y
    

    More detailed MCP configuration would be handled in the MCP section in Settings.

  4. ngxson commented on Mar 19, 2026

    @ngxson
    CollaboratorAuthor

    @pwilkin @allozaur small update for you, so the plan is much clearer now:

    1. For the first step, we will add support for built-in tools to server + web UI. I'll push the PR shortly and that will contain tools inspired by vscode's agent impl like grep_file, edit_file, glob, etc. This allows working with large file / large directory without using up model's context
    2. The 2nd step would be to support this on CLI. Since tools are in OAI format, this will completely bypass MCP stuff, thus will be trivial to implement
    3. Next step is to allow loading mcp.json which contains stdio and HTTP MCP servers. The /cors-proxy endpoint will be refactored such that it allows tunneling both HTTP and stdio. Web UI will need to adapt to this change
    4. Then, we will need to implement C++ MCP client on CLI. That should mostly the same as MCP for llama-cli #19373 , so just asking if you're OK with moving your changes to the new API @pwilkin ? I will give you more details when we arrive at step 3

    Note that I'm not having strong opinion about whether we should leave C++ MCP client inside CLI, or bring it to server, but let's come back to this point a bit later

  5. pwilkin commented on Mar 19, 2026

    @pwilkin
    Member

    Yeah, looks fine. Should I upload what I did on the registry until now? It's mostly a vibed prototype, but most of it aligns with this vision pretty well.

  6. ngxson commented on Mar 19, 2026

    @ngxson
    CollaboratorAuthor

    Hmm yeah if you have a branch, you can give me a link, I can have a quick look (so no need to create a new PR)

  7. 4 remaining items

  8. dwrz commented on Apr 30, 2026

    @dwrz

    Excited to see the built-in tools -- thank you.

    Is there any possibility the tool registry could enable user-defined tools? Emacs' gptel mode allows for this; with Go I've mapped YAML / JSON to ExecCommand.

  9. niutech commented on Jun 12, 2026

    @niutech

    @pwilkin Is there any PR?

  10. pwilkin commented on Jun 12, 2026

    @pwilkin
    Member

    @niutech we're setting up the proper backend structures first.

  11. added theissue type on Jun 16, 2026
  12. github-actions commented on Jul 31, 2026

    @github-actions
    Contributor

    This issue was closed because it has been inactive for 14 days since being marked as stale.

  13. niutech commented on Jul 31, 2026

    @niutech

    @pwilkin Why was it closed when it is on the roadmap?

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

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions