Skip to content

feat(cli): implement all template functions, auto-install local tools, and config fixes#91

Merged
appcypher merged 1 commit intomainfrom
appcypher/template-functions-auto-install-config-fixes
Feb 5, 2026
Merged

feat(cli): implement all template functions, auto-install local tools, and config fixes#91
appcypher merged 1 commit intomainfrom
appcypher/template-functions-auto-install-config-fixes

Conversation

@appcypher
Copy link
Copy Markdown
Member

PR Title: feat(cli): implement all template functions, auto-install local tools, and config fixes

Summary

  • Implement all 13 MCPBX spec template functions with a recursive descent expression parser, replacing the previous flat if/else chain that only supported base64 and basicAuth
  • Add auto-install for local path tools so that tool info/call/run/config set on a local path automatically links the tool, enabling config to be stored by name
  • Fix config unset to work on stored config names even when the tool is not installed
  • Fix config re-prompting so optional fields are not re-prompted on subsequent runs
  • Add single-letter subcommand aliases and host add validation

These changes make local tool workflows seamless: users can point at a local directory and the CLI handles installation, config storage, and cleanup without manual install steps.

Changes

lib/vars.rs (+684/-68) - Complete rewrite of template variable substitution:

  • Replace flat if/else dispatch with recursive descent parser (eval_expr, resolve_var, split_args, eval_func)
  • Implement all 13 MCPBX template functions: base64, base64url, urlEncode, hex, concat, lower, upper, trim, default, basicAuth, bearer, timestamp, uuid, jsonEncode
  • Support nested function calls like ${base64(concat(user_config.user, ':', user_config.pass))}
  • Fix basicAuth to include "Basic " prefix per spec
  • Add 37 unit tests covering all functions, nesting, edge cases, and error handling

lib/handlers/tool/registry.rs (+109) - New local tool linking functions:

  • Add LinkResult enum (Linked, AlreadyLinked, Conflict)
  • Add link_local_tool for symlink creation with conflict detection
  • Add link_local_tool_force for overwriting existing links
  • Add cross-platform create_symlink helper

lib/handlers/tool/common.rs (+99/-6) - Auto-install integration:

  • Add auto_install_local_tool shared helper with conflict prompt (Overwrite? [y/N])
  • Call auto-install in prepare_tool when is_installed = false, covering tool info/call/run

lib/handlers/tool/config_cmd.rs (+64/-17) - Config command fixes:

  • Call auto-install in config_set for local path tools
  • Add resolve_tool_for_config helper that falls back to PluginRef lookup when tool resolution fails
  • Update unset_tool_keys and unset_tool_all_keys to use the fallback resolver
  • Add tool_config_exists function for checking config file existence on disk

lib/handlers/tool/call.rs (+46/-14) - Config prompt improvements:

  • Return has_saved_config from parse_user_config based on actual file existence
  • Update prompt_missing_user_config to only prompt required fields without defaults on subsequent runs

lib/handlers/tool/host_cmd.rs (+14) - Host add validation:

  • Validate user-specified tools are installed via FilePluginResolver::resolve_tool
  • Error with hint to run tool install if not found

lib/commands.rs (+14/-7) - Subcommand aliases:

  • Add aliases for config subcommands: s (set), g (get), l (list), u (unset)
  • Add aliases for host subcommands: a (add), r (remove), l (list), p (preview)

Test Plan

  • Run cargo build to verify compilation
  • Run cargo test to verify all 140 tests pass (including 37 new template function tests)
  • Test template functions: tool info external/mongodb with a manifest using ${default(user_config.connection_string, '')} should resolve without "Undefined variable" errors
  • Test auto-install: tool info ./path/to/local/tool should print "Linked name from path" on first use
  • Test auto-install conflict: manually install a tool, then run tool info ./different/path for same name -- should prompt "Overwrite? [y/N]"
  • Test config unset fallback: tool config set ./local-tool key=value, then uninstall the tool, then tool config unset local-tool --all should succeed
  • Test config re-prompting: run tool info external/mongodb twice -- second run should not re-prompt for optional fields
  • Test subcommand aliases: tool config s <tool>, tool host a claude-desktop
  • Test host add validation: tool host add claude-desktop nonexistent-tool should error with install hint

…, and config fixes

Rewrite template variable substitution with a recursive descent
expression parser supporting all 13 MCPBX spec functions: base64,
base64url, urlEncode, hex, concat, lower, upper, trim, default,
basicAuth, bearer, timestamp, uuid, and jsonEncode. Supports
nested calls like ${base64(concat(user_config.user, ':', pass))}.

Add auto-install for local path tools: when running tool info,
call, run, or config set on a local path, automatically create a
symlink in ~/.tool/tools/ so config is stored by name. Prompts
on conflict with existing link.

Additional changes:
- Fix config unset to work on stored config names when the tool
  is not installed, by falling back to PluginRef lookup
- Fix config re-prompting: only prompt for required fields on
  subsequent runs when a saved config already exists
- Add single-letter aliases for config (s/g/l/u) and host
  (a/r/l/p) subcommands
- Validate user-specified tools are installed in host add
@appcypher appcypher merged commit 4c375ed into main Feb 5, 2026
6 checks passed
@appcypher appcypher deleted the appcypher/template-functions-auto-install-config-fixes branch February 5, 2026 13:27
appcypher added a commit that referenced this pull request Feb 6, 2026
Changes since v0.1.13:

Features:
- Add progress bars to tool pack with improved UX (#97)
- Add --json and --concise support to tool config get (#95)
- Add OpenCode as supported MCP host (#94)
- Add tool config list <ref|path> command (#93)
- Implement all template functions and auto-install local tools (#91)

Fixes:
- Pass Authorization header from manifest to HTTP transport (#96)
- Fix OAuth re-authentication flow (#93)
- Correct config path derivation for path-resolved tools (#92)
appcypher added a commit that referenced this pull request Feb 6, 2026
Changes since v0.1.13:

Features:
- Add progress bars to tool pack with improved UX (#97)
- Add --json and --concise support to tool config get (#95)
- Add OpenCode as supported MCP host (#94)
- Add tool config list <ref|path> command (#93)
- Implement all template functions and auto-install local tools (#91)

Fixes:
- Pass Authorization header from manifest to HTTP transport (#96)
- Fix OAuth re-authentication flow (#93)
- Correct config path derivation for path-resolved tools (#92)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant