feat: add optional working_dir to MCP and LSP toolset configs#2460
Open
simonferquel-clanker wants to merge 3 commits intodocker:mainfrom
Open
feat: add optional working_dir to MCP and LSP toolset configs#2460simonferquel-clanker wants to merge 3 commits intodocker:mainfrom
simonferquel-clanker wants to merge 3 commits intodocker:mainfrom
Conversation
- Add WorkingDir field to Toolset struct (pkg/config/latest/types.go) - Validate that working_dir is only used with type 'mcp' or 'lsp' - Resolve working_dir relative to agent's working directory at process start - Propagate working_dir from top-level mcps: definitions to agent toolsets - Add resolveToolsetWorkingDir helper in registry.go - Add tests: validate_test.go, mcps_test.go, registry_test.go - Add example: examples/toolset-working-dir.yaml - Update agent-schema.json for Toolset and MCPToolset Closes docker#2459 Assisted-By: docker-agent
B1: pass resolved CWD to NewGatewayToolset; gateway-based MCPs now
honour working_dir. Remote MCP toolsets reject working_dir at
validation time (no local subprocess).
B2: call path.ExpandPath in resolveToolsetWorkingDir so ~ and
${VAR}/$VAR are expanded before path operations. Use filepath.Abs
when joining a relative path with the agent dir (fixes file://./backend
LSP root URI).
S1: add checkDirExists helper; createMCPTool and createLSPTool now
surface a clear error if working_dir does not exist at tool-creation
time.
S2: doc comment on resolveToolsetWorkingDir explains no-containment-
check posture (working_dir is treated like command/args).
S3: filepath.Abs on relative+non-empty-agentDir path ensures LSP
rootURI is always absolute.
S4: validation rejects working_dir on remote MCP toolsets.
S5: comment in applyMCPDefaults explains empty-string inheritance
semantics.
S6: doc comment covers the empty-agent-dir+relative edge case.
Nits: example model → gpt-5-mini; test name → 'bare relative dir';
schema descriptions aligned; import groups tidied; hard-coded
non-existent path in test → t.TempDir()+'/missing'.
N5: integration tests added:
- TestCreateMCPTool_WorkingDir_ReachesSubprocess
- TestCreateMCPTool_RelativeWorkingDir_ResolvedAgainstAgentDir
- TestCreateMCPTool_NonexistentWorkingDir_ReturnsError
- TestCreateLSPTool_WorkingDir_ReachesHandler
Also add WorkingDir() accessors on *mcp.Toolset and *builtin.LSPTool
to support the above integration tests.
Assisted-By: docker-agent
…epathJoin lint rule Assisted-By: docker-agent
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
working_dirfield to MCP and LSP toolset configurations, allowing these processes to be launched from a directory other than the agent's working directory.Closes #2459
Changes
pkg/config/latest/types.go— NewWorkingDirfield onToolsetstructpkg/config/latest/validate.go— Validation:working_dironly valid for typesmcpandlsppkg/config/mcps.go— Propagateworking_dirfrom top-levelmcps:definitions to referencing agent toolsets (existing toolset value takes precedence)pkg/teamloader/registry.go—resolveToolsetWorkingDirhelper;createMCPToolandcreateLSPToolresolve and pass the working directory to the processagent-schema.json—working_diradded toToolsetandMCPToolsetschema definitionsexamples/toolset-working-dir.yaml— New example demonstrating the featureBehaviour
working_diris optional; omitting it keeps existing behaviour (process starts from agent's working directory)mcps:section,working_diris inherited by referencing toolsets; a toolset-level value overrides the definition