Skip to content

MCP: add templated tool descriptions and tool name prefixing for HTTP/STDIO servers#63

Merged
nmaguiar merged 9 commits intomasterfrom
codex/add-handlebars-template-flag-to-ojobmcp.yaml
Mar 10, 2026
Merged

MCP: add templated tool descriptions and tool name prefixing for HTTP/STDIO servers#63
nmaguiar merged 9 commits intomasterfrom
codex/add-handlebars-template-flag-to-ojobmcp.yaml

Conversation

@nmaguiar
Copy link
Copy Markdown
Collaborator

@nmaguiar nmaguiar commented Mar 7, 2026

Motivation

  • Allow MCP servers to expose tools with a configurable external prefix while keeping internal fns/fnsMeta keys unchanged and to evaluate tool description fields as Handlebars templates using current job args.

Description

  • Added new arguments tplDesc and toolPrefix with defaults and checks in both HTTP and STDIO MCP jobs to enable templated descriptions and optional tool name prefixing.
  • Implemented helper functions _applyTemplateToDescriptions, _prefixToolName, _resolveToolName, and _toToolMeta to walk/transform metadata, prefix tool names for exposure, and resolve incoming prefixed names back to internal keys.
  • Updated tools/list responses to return prefixed metadata produced via _toToolMeta, and updated tools/call handling to resolve the incoming params.name to the internal function key before invoking args.fns (including updating thrown/error messages accordingly).
  • Adjusted STDIO MCP server to expose prefixed tool names in its fs mapping and pass prefixed metadata to ow.server.mcpStdio, while preserving internal args.fns mapping and existing error/result normalization logic.

Testing

  • No automated tests were run as part of this change.

Nuno Miguel Aguiar added 2 commits March 7, 2026 04:57
  - Extracted common `$t` template handling into a single `_applyTemplate` helper.
  - Replaced duplicated `_applyTemplateToDescriptions` implementations with a unified call.
  - Updated job resolution to use the new helper for both full and description‑only templates.
  - Minor cleanup of variable names and comments.

  This refactor improves maintainability and reduces code duplication while preserving existing behavior.
@nmaguiar nmaguiar marked this pull request as ready for review March 9, 2026 20:30
@nmaguiar nmaguiar self-assigned this Mar 9, 2026
@nmaguiar nmaguiar requested a review from Copilot March 9, 2026 20:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the MCP HTTP and STDIO server jobs to (1) optionally render tool/metadata descriptions as Handlebars templates using the current oJob args and (2) optionally expose tools under a configurable external name prefix while keeping internal fns/fnsMeta keys unchanged.

Changes:

  • Added tplDesc and toolPrefix args (with defaults/checks) to both HTTP and STDIO MCP jobs.
  • Implemented metadata transformation helpers to template description fields and to prefix/resolve tool names on list/call paths.
  • Updated package manifest version and included new .github artifacts in the opack file list/hash.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
oJobMCP.yaml Adds templated tool descriptions and tool name prefixing for MCP HTTP/STDIO servers; updates tools list/call behavior accordingly.
.package.yaml Bumps package version and includes .github assets in packaged files and hashes.
Comments suppressed due to low confidence (2)

oJobMCP.yaml:171

  • In this error path you're throwing a string but later format/log the error using e.message. When e is a string, e.message is undefined, so the client will get an unhelpful message. Prefer throwing an Error (or normalizing with String(e) in the catch) so logs and responses always contain the actual message.
                      } else {
                        throw "Function not found: " + _toolName
                      }
                    } catch(e) {
                      logErr(`Error executing tool '${params.name}': ${e.message}`)
                      _res = {
                          content: [{
                              type: "text",
                              text: `Error executing tool '${params.name}': ${e.message}`
                          }],

oJobMCP.yaml:334

  • Same issue as above: this handler throws a string ("Function not found: ...") but the catch block logs/returns e.message, which will be undefined for string exceptions. Throw an Error or use String(e) in the catch when building the log/response.
                    } else {
                      throw "Function not found: " + _toolName
                    }
                  } catch(e) {
                    logErr(`Error executing tool '${params.name}': ${e.message}`)
                    _res = {
                        content: [{
                            type: "text",
                            text: `Error executing tool '${params.name}': ${e.message}`
                        }],

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread oJobMCP.yaml Outdated
Comment thread oJobMCP.yaml Outdated
Comment on lines 494 to 511
@@ -420,7 +510,7 @@ jobs:
}
})
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.keys(args.fns).map(...) is used only for side effects (populating fs). Using map here is misleading and allocates an unused array; use forEach (or a for...of) instead to make the intent clear.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot open a new pull request to apply changes based on this feedback

Comment thread oJobMCP.yaml Outdated
nmaguiar and others added 2 commits March 9, 2026 21:40
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 9, 2026

@nmaguiar I've opened a new pull request, #64, to work on those changes. Once the pull request is ready, I'll request review from you.

nmaguiar and others added 4 commits March 9, 2026 21:41
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: nmaguiar <11761746+nmaguiar@users.noreply.github.com>
[WIP] Update templated tool descriptions for HTTP/STDIO servers
@nmaguiar nmaguiar merged commit 7155493 into master Mar 10, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Continuous Enhancement Mar 10, 2026
@nmaguiar nmaguiar deleted the codex/add-handlebars-template-flag-to-ojobmcp.yaml branch March 10, 2026 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Development

Successfully merging this pull request may close these issues.

3 participants