Support directory-scoped MCP tool calls#104
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds directory-scoped routing to the MCP server so tool calls can target the active workspace directory (instead of the MCP process launch directory), with documentation and tests to validate the new argument is plumbed through.
Changes:
- Added optional
directoryparameter to MCP tool parameter structs and tool JSON schemas. - Updated MCP backend to route
workspace_status,search_code, andindex_repositoryto per-directory backends (with caching). - Added/updated tests and documentation for the new
directoryargument and behavior.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| mintlify/commands/mcp.mdx | Documents the new optional directory argument for MCP tools. |
| internal/mcp/types.go | Adds WorkspaceStatusParams and Directory fields to MCP params; updates service interface signature. |
| internal/mcp/tools.go | Exposes directory in tool input schemas and plumbs args into WorkspaceStatus. |
| internal/mcp/server_test.go | Updates fake service interface and adds assertions that directory is present/forwarded. |
| internal/cli/start.go | Switches MCP startup to preview paths and passes state/db inputs into backend config for per-directory routing. |
| internal/cli/mcp_backend_test.go | Adds tests validating directory affects workspace_status and rejects file paths. |
| internal/cli/mcp_backend.go | Implements directory routing via cached child backends and directory normalization/validation. |
| README.md | Documents that MCP tools accept optional directory and the installed skill passes the active repo path. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+363
to
+367
| func (b *mcpBackend) backendForDirectory(directory string) (*mcpBackend, error) { | ||
| rootAbs, ok, err := normalizeMCPDirectory(directory) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
Comment on lines
+372
to
+380
| b.childrenMu.Lock() | ||
| defer b.childrenMu.Unlock() | ||
|
|
||
| if b.children == nil { | ||
| b.children = map[string]*mcpBackend{} | ||
| } | ||
| if child, ok := b.children[rootAbs]; ok { | ||
| return child, nil | ||
| } |
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
directoryargument to all unch MCP tools:workspace_status,search_code, andindex_repository.workspace_statuscheap: it previews the target state path and does not create.semsearch.directoryargument in README and Mintlify MCP docs.Fixes #98.
Tests
go test ./internal/mcp ./internal/cligo test ./...go run ./cmd/unch start mcp+workspace_statuswithdirectory