embark-cli 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/.claude/CLAUDE.md +33 -0
  2. package/.claude/settings.local.json +32 -0
  3. package/.github/WORKFLOWS.md +147 -0
  4. package/.github/workflows/ci.yml +49 -0
  5. package/.github/workflows/publish.yml +109 -0
  6. package/.idea/embark-remote-mcp.iml +9 -0
  7. package/.idea/encodings.xml +4 -0
  8. package/.idea/indexLayout.xml +8 -0
  9. package/.idea/vcs.xml +6 -0
  10. package/.mcp.json +14 -0
  11. package/GIT_DISCOVERY.md +231 -0
  12. package/INTEGRATION_TESTING.md +243 -0
  13. package/MULTI_REPOSITORY_SEARCH.md +242 -0
  14. package/README.md +434 -0
  15. package/dist/auth/auth-helper.d.ts +3 -0
  16. package/dist/auth/auth-helper.d.ts.map +1 -0
  17. package/dist/auth/auth-helper.js +171 -0
  18. package/dist/auth/auth-helper.js.map +1 -0
  19. package/dist/auth/index.d.ts +4 -0
  20. package/dist/auth/index.d.ts.map +1 -0
  21. package/dist/auth/index.js +24 -0
  22. package/dist/auth/index.js.map +1 -0
  23. package/dist/auth/jba-login.d.ts +17 -0
  24. package/dist/auth/jba-login.d.ts.map +1 -0
  25. package/dist/auth/jba-login.js +345 -0
  26. package/dist/auth/jba-login.js.map +1 -0
  27. package/dist/auth/types.d.ts +16 -0
  28. package/dist/auth/types.d.ts.map +1 -0
  29. package/dist/auth/types.js +3 -0
  30. package/dist/auth/types.js.map +1 -0
  31. package/dist/config.d.ts +26 -0
  32. package/dist/config.d.ts.map +1 -0
  33. package/dist/config.js +54 -0
  34. package/dist/config.js.map +1 -0
  35. package/dist/embark-client.d.ts +56 -0
  36. package/dist/embark-client.d.ts.map +1 -0
  37. package/dist/embark-client.js +543 -0
  38. package/dist/embark-client.js.map +1 -0
  39. package/dist/git-utils.d.ts +47 -0
  40. package/dist/git-utils.d.ts.map +1 -0
  41. package/dist/git-utils.js +232 -0
  42. package/dist/git-utils.js.map +1 -0
  43. package/dist/handlers.d.ts +80 -0
  44. package/dist/handlers.d.ts.map +1 -0
  45. package/dist/handlers.js +301 -0
  46. package/dist/handlers.js.map +1 -0
  47. package/dist/index.d.ts +3 -0
  48. package/dist/index.d.ts.map +1 -0
  49. package/dist/index.js +165 -0
  50. package/dist/index.js.map +1 -0
  51. package/dist/logger.d.ts +4 -0
  52. package/dist/logger.d.ts.map +1 -0
  53. package/dist/logger.js +92 -0
  54. package/dist/logger.js.map +1 -0
  55. package/dist/stats-server.d.ts +3 -0
  56. package/dist/stats-server.d.ts.map +1 -0
  57. package/dist/stats-server.js +623 -0
  58. package/dist/stats-server.js.map +1 -0
  59. package/dist/stats.d.ts +118 -0
  60. package/dist/stats.d.ts.map +1 -0
  61. package/dist/stats.js +206 -0
  62. package/dist/stats.js.map +1 -0
  63. package/dist/tools.d.ts +9 -0
  64. package/dist/tools.d.ts.map +1 -0
  65. package/dist/tools.js +62 -0
  66. package/dist/tools.js.map +1 -0
  67. package/package.json +47 -0
  68. package/test-git-discovery.mjs +322 -0
  69. package/test-multi-repo-filters.mjs +151 -0
  70. package/test-multiple-roots.mjs +436 -0
  71. package/test-roots.mjs +306 -0
  72. package/test-snippet-extraction.mjs +136 -0
  73. package/watch-logs.sh +78 -0
@@ -0,0 +1,33 @@
1
+ # Tools
2
+
3
+ ## Semantic Code Search (EmbArk)
4
+
5
+ You have access to the `mcp__embark-mcp__semantic_code_search` tool for searching the codebase semantically.
6
+ This tool can search for code snippets related in meaning to the search query and search objective.
7
+
8
+ ### When to use semantic search:
9
+ - Understanding unfamiliar codebases or locating specific functionality.
10
+ - Finding implementations, definitions, or usage patterns.
11
+ - Identifying code related to specific features or concepts.
12
+ - Before making changes to understand the context and impact.
13
+
14
+ ### Usage rules:
15
+ - The tool searches by MEANING, not just exact string matches.
16
+ - The tool takes the `text` parameter that should combine both what you're looking for and why:
17
+ - Construct the `text` parameter by combining: what to find + search objective.
18
+ - Make search objective in the query specific and self-contained, describe what you are trying to achieve by search and how the search results should help.
19
+ - Objective should always provide an additional context of the query, describing the higher-level task.
20
+ - The tool optionally takes the `pathFilter` parameter to narrow the search to a specific directory or file:
21
+ - Using `pathFilter` dramatically improves search relevance and precision.
22
+ - Semantic search without path constraints might return irrelevant results from unrelated modules.
23
+ - If not provided, the whole project is searched.
24
+
25
+ ### Examples:
26
+ - `"text"="Refactor `MyFunction` to handle async operations", "pathFilter"="path/to/module"`: Searches `MyFunction` within the specified directory for refactoring.
27
+ - `"text"="Find `authorization` to add OAuth2 support to existing auth system", "pathFilter"="path/to/file/example.kt"`: Searches `authorization` inside the specified file to add OAuth2 support.
28
+ - `"text"="Find `class User` to add email validation to user model"`: Finds the definition of class `User` to add email validation.
29
+ - `"text"="Find `class User` to add email validation to user model", "pathFilter"="path/to/file/example.kt"`: Finds the definition of class `User` inside the specified file to add email validation.
30
+ - `"text"="Locate query with retries to improve error handling in database queries"`: Searches for anything containing `query*with*retries` in directory names, filenames, symbol names and semantic matches by meaning. It also returns a code line with the exact phrase `query with retries`.
31
+ - `"text"="Find `fun getConfig` to change default headers in authentication", "pathFilter"="path/to/module/submodule"`: Searches for `fun getConfig` within the specified directory `path/to/module/submodule` to change the default headers in authentication.
32
+
33
+ Use this tool proactively when you need to understand code structure or locate relevant implementations.
@@ -0,0 +1,32 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(mkdir:*)",
5
+ "Bash(npm install)",
6
+ "Bash(npm run build:*)",
7
+ "WebFetch(domain:docs.anthropic.com)",
8
+ "Bash(find:*)",
9
+ "Bash(ls:*)",
10
+ "Bash(claude mcp add:*)",
11
+ "Bash(claude mcp:*)",
12
+ "WebFetch(domain:modelcontextprotocol.io)",
13
+ "WebFetch(domain:github.com)",
14
+ "Bash(npm install:*)",
15
+ "mcp__embark-remote-mcp__semantic_code_search",
16
+ "Bash(chmod:*)",
17
+ "Bash(node test-roots.mjs)",
18
+ "Bash(node:*)",
19
+ "Read(//Users/dmitry.loktev/.embark/**)",
20
+ "Bash(cat:*)",
21
+ "Bash(ENABLE_REMOTE_LOGS=true node:*)",
22
+ "Bash(ENABLE_LOCAL_LOGS=true node:*)",
23
+ "Bash(ENABLE_LOCAL_LOGS=1 node dist/index.js:*)",
24
+ "mcp__jetbrains-app__semantic_code_search"
25
+ ],
26
+ "deny": []
27
+ },
28
+ "enableAllProjectMcpServers": true,
29
+ "enabledMcpjsonServers": [
30
+ "embark-remote-mcp"
31
+ ]
32
+ }
@@ -0,0 +1,147 @@
1
+ # GitHub Actions Workflows
2
+
3
+ This repository uses GitHub Actions for continuous integration and deployment.
4
+
5
+ ## Workflows
6
+
7
+ ### 1. CI Workflow (`.github/workflows/ci.yml`)
8
+
9
+ **Triggers:**
10
+ - Push to `main` or `develop` branches
11
+ - Pull requests to `main` or `develop` branches
12
+
13
+ **Jobs:**
14
+ - Runs on Node.js versions 18, 20, and 22
15
+ - Installs dependencies
16
+ - Builds the project
17
+ - Runs tests (if available)
18
+ - Verifies build artifacts
19
+ - Validates package can be packed
20
+
21
+ ### 2. Publish Workflow (`.github/workflows/publish.yml`)
22
+
23
+ **Triggers:**
24
+ - Manual trigger via GitHub UI (workflow_dispatch)
25
+ - Requires selecting version bump type: patch, minor, or major
26
+
27
+ **Jobs:**
28
+ - Checks out code
29
+ - Configures Git for automated commits
30
+ - Sets up Node.js 20
31
+ - Installs dependencies
32
+ - Builds the project
33
+ - Runs tests (if available)
34
+ - **Automatically bumps version** in package.json based on input
35
+ - Checks if version is already published to NPM
36
+ - Commits the version bump back to the repository
37
+ - Creates and pushes a git tag (e.g., v1.0.17)
38
+ - Publishes to NPM with provenance (if version is new)
39
+
40
+ ## Setting Up NPM Token
41
+
42
+ To enable automatic publishing to NPM, you need to configure the `NPM_TOKEN` secret:
43
+
44
+ ### Step 1: Generate an NPM Access Token
45
+
46
+ 1. Log in to [npmjs.com](https://www.npmjs.com/)
47
+ 2. Click on your profile picture → "Access Tokens"
48
+ 3. Click "Generate New Token" → "Classic Token"
49
+ 4. Select "Automation" type (for CI/CD)
50
+ 5. Copy the generated token
51
+
52
+ ### Step 2: Add Token to GitHub Secrets
53
+
54
+ 1. Go to your GitHub repository
55
+ 2. Navigate to **Settings** → **Secrets and variables** → **Actions**
56
+ 3. Click **"New repository secret"**
57
+ 4. Name: `NPM_TOKEN`
58
+ 5. Value: Paste your NPM token
59
+ 6. Click **"Add secret"**
60
+
61
+ ## Publishing a New Version
62
+
63
+ The publish workflow is fully automated and handles version bumping for you:
64
+
65
+ ### Steps to Publish:
66
+
67
+ 1. Go to the **Actions** tab in your GitHub repository
68
+ 2. Select **"Publish to NPM"** workflow from the left sidebar
69
+ 3. Click **"Run workflow"** button (top right)
70
+ 4. Choose the version bump type:
71
+ - **patch**: Bug fixes and minor updates (1.0.16 → 1.0.17)
72
+ - **minor**: New features (1.0.16 → 1.1.0)
73
+ - **major**: Breaking changes (1.0.16 → 2.0.0)
74
+ 5. Click **"Run workflow"** to start
75
+
76
+ ### What Happens Automatically:
77
+
78
+ 1. ✅ Runs build and tests
79
+ 2. ✅ Bumps version in `package.json` and `package-lock.json`
80
+ 3. ✅ Checks if version already exists on NPM
81
+ 4. ✅ Commits the version bump with message: `chore: bump version to vX.Y.Z`
82
+ 5. ✅ Creates and pushes a git tag (e.g., `v1.0.17`)
83
+ 6. ✅ Publishes to NPM with provenance
84
+
85
+ **Note**: You don't need to manually update `package.json` or create git tags anymore - the workflow handles everything!
86
+
87
+ ## Workflow Features
88
+
89
+ ### Build & Test
90
+ - Uses `npm ci` for reproducible installs
91
+ - Runs `npm run build` to compile TypeScript
92
+ - Executes `npm test` if test script exists
93
+
94
+ ### Version Check
95
+ - Automatically checks if the version in `package.json` is already published
96
+ - Skips publishing if version already exists on NPM
97
+ - Prevents accidental republishing of the same version
98
+
99
+ ### NPM Provenance
100
+ - Publishes with `--provenance` flag for supply chain security (public repos only)
101
+ - Links published package to the specific commit and workflow
102
+ - Provides transparency about package origins
103
+ - **Note**: Provenance is automatically disabled for internal/private repositories as it's only supported for public repos
104
+
105
+ ### Public Access
106
+ - Publishes with `--access public` for scoped or public packages
107
+ - Remove this flag if publishing a private package
108
+
109
+ ## Troubleshooting
110
+
111
+ ### "Version already published" Error
112
+ - The workflow automatically checks NPM before publishing
113
+ - If you see this error, the version already exists
114
+ - Solution: Run the workflow again with a higher bump type (e.g., use `minor` instead of `patch`)
115
+
116
+ ### NPM Token Invalid
117
+ - Verify token is an "Automation" type token
118
+ - Check token hasn't expired
119
+ - Regenerate token and update GitHub secret
120
+
121
+ ### Build Failures
122
+ - Check Node.js version compatibility
123
+ - Ensure all dependencies are properly declared
124
+ - Review build logs in Actions tab
125
+
126
+ ### Provenance Error (E422)
127
+ - If you see "Unsupported GitHub Actions source repository visibility: internal"
128
+ - This is expected - provenance is only supported for public repositories
129
+ - The workflow automatically handles this by publishing without provenance for internal/private repos
130
+ - No action needed on your part
131
+
132
+ ### Push Rejected / Protected Branch
133
+ - Ensure the workflow has `contents: write` permission (already configured)
134
+ - If branch protection is enabled on `main`, you may need to:
135
+ - Allow GitHub Actions to bypass branch protection rules
136
+ - Or temporarily disable "Require pull request reviews before merging" for bots
137
+
138
+ ### Workflow Not Visible
139
+ - Ensure the workflow file is committed to the `main` branch
140
+ - Check `.github/workflows/publish.yml` exists in the repository
141
+
142
+ ## Security Notes
143
+
144
+ - Never commit NPM tokens to the repository
145
+ - Use GitHub Secrets for sensitive credentials
146
+ - Rotate tokens periodically
147
+ - Use Automation tokens (not classic tokens with full access)
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ - develop
8
+ pull_request:
9
+ branches:
10
+ - main
11
+ - develop
12
+
13
+ jobs:
14
+ build-and-test:
15
+ runs-on: ubuntu-latest
16
+
17
+ strategy:
18
+ matrix:
19
+ node-version: [20, 22]
20
+
21
+ steps:
22
+ - name: Checkout code
23
+ uses: actions/checkout@v4
24
+
25
+ - name: Setup Node.js ${{ matrix.node-version }}
26
+ uses: actions/setup-node@v4
27
+ with:
28
+ node-version: ${{ matrix.node-version }}
29
+ cache: 'npm'
30
+
31
+ - name: Install dependencies
32
+ run: npm ci
33
+
34
+ - name: Build project
35
+ run: npm run build
36
+
37
+ - name: Run tests (if test script exists)
38
+ run: npm test --if-present
39
+
40
+ - name: Check dist directory
41
+ run: |
42
+ if [ ! -d "dist" ]; then
43
+ echo "Error: dist directory not created"
44
+ exit 1
45
+ fi
46
+ echo "Build artifacts created successfully"
47
+
48
+ - name: Verify package can be packed
49
+ run: npm pack --dry-run
@@ -0,0 +1,109 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version_bump:
7
+ description: 'Version bump type'
8
+ required: true
9
+ type: choice
10
+ options:
11
+ - patch
12
+ - minor
13
+ - major
14
+ default: patch
15
+
16
+ jobs:
17
+ build-test-publish:
18
+ runs-on: ubuntu-latest
19
+
20
+ permissions:
21
+ contents: write # Required to push commits and tags
22
+ id-token: write # Required for provenance
23
+
24
+ steps:
25
+ - name: Checkout code
26
+ uses: actions/checkout@v4
27
+ with:
28
+ fetch-depth: 0 # Fetch all history for proper versioning
29
+ token: ${{ secrets.GITHUB_TOKEN }}
30
+
31
+ - name: Configure Git
32
+ run: |
33
+ git config user.name "github-actions[bot]"
34
+ git config user.email "github-actions[bot]@users.noreply.github.com"
35
+
36
+ - name: Setup Node.js
37
+ uses: actions/setup-node@v4
38
+ with:
39
+ node-version: '20'
40
+ registry-url: 'https://registry.npmjs.org'
41
+ cache: 'npm'
42
+
43
+ - uses: actions/setup-node@v4
44
+ with:
45
+ node-version: '20'
46
+ registry-url: 'https://registry.npmjs.org'
47
+
48
+ # Ensure npm 11.5.1 or later is installed
49
+ - name: Update npm
50
+ run: npm install -g npm@latest
51
+
52
+ - name: Install dependencies
53
+ run: npm ci
54
+
55
+ - name: Build project
56
+ run: npm run build
57
+
58
+ - name: Run tests (if test script exists)
59
+ run: npm test --if-present
60
+
61
+ - name: Bump version
62
+ id: version
63
+ run: |
64
+ # Bump version in package.json
65
+ NEW_VERSION=$(npm version ${{ inputs.version_bump }} --no-git-tag-version)
66
+ echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
67
+ echo "New version: $NEW_VERSION"
68
+
69
+ - name: Check if version is already published
70
+ id: check-version
71
+ run: |
72
+ PACKAGE_NAME=$(node -p "require('./package.json').name")
73
+ PACKAGE_VERSION=$(node -p "require('./package.json').version")
74
+
75
+ if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then
76
+ echo "Version $PACKAGE_VERSION is already published"
77
+ echo "should_publish=false" >> $GITHUB_OUTPUT
78
+ else
79
+ echo "Version $PACKAGE_VERSION is not published yet"
80
+ echo "should_publish=true" >> $GITHUB_OUTPUT
81
+ fi
82
+
83
+ - name: Commit version bump
84
+ if: steps.check-version.outputs.should_publish == 'true'
85
+ run: |
86
+ git add package.json package-lock.json
87
+ git commit -m "chore: bump version to ${{ steps.version.outputs.new_version }}"
88
+ git tag ${{ steps.version.outputs.new_version }}
89
+
90
+ - name: Push changes
91
+ if: steps.check-version.outputs.should_publish == 'true'
92
+ run: |
93
+ git push origin main
94
+ git push origin ${{ steps.version.outputs.new_version }}
95
+
96
+ - name: Publish to NPM (with provenance for public repos)
97
+ if: steps.check-version.outputs.should_publish == 'true' && github.event.repository.visibility == 'public'
98
+ run: npm publish --provenance --access public
99
+
100
+ - name: Publish to NPM (without provenance for private/internal repos)
101
+ if: steps.check-version.outputs.should_publish == 'true' && github.event.repository.visibility != 'public'
102
+ run: npm publish --access public
103
+
104
+ - name: Skip publishing
105
+ if: steps.check-version.outputs.should_publish == 'false'
106
+ run: |
107
+ echo "Skipping publish - version already exists on NPM"
108
+ echo "Please increment the version manually or choose a different bump type"
109
+ exit 1
@@ -0,0 +1,9 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="JAVA_MODULE" version="4">
3
+ <component name="NewModuleRootManager" inherit-compiler-output="true">
4
+ <exclude-output />
5
+ <content url="file://$MODULE_DIR$" />
6
+ <orderEntry type="inheritedJdk" />
7
+ <orderEntry type="sourceFolder" forTests="false" />
8
+ </component>
9
+ </module>
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
4
+ </project>
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="UserContentModel">
4
+ <attachedFolders />
5
+ <explicitIncludes />
6
+ <explicitExcludes />
7
+ </component>
8
+ </project>
package/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="" vcs="Git" />
5
+ </component>
6
+ </project>
package/.mcp.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "mcpServers": {
3
+ "embark-remote-mcp": {
4
+ "type": "stdio",
5
+ "command": "node",
6
+ "args": [
7
+ "dist/index.js"
8
+ ],
9
+ "env": {
10
+ "ENABLE_LOCAL_LOGS": true
11
+ }
12
+ }
13
+ }
14
+ }
@@ -0,0 +1,231 @@
1
+ # Git Repository Discovery from Roots
2
+
3
+ This document explains how the Embark MCP server automatically discovers Git repositories from client-provided roots.
4
+
5
+ ## How It Works
6
+
7
+ ### 1. Server Requests Roots from Client
8
+
9
+ When the server starts and connects to a client (like Claude Code), it requests the list of roots:
10
+
11
+ ```typescript
12
+ const response = await server.listRoots();
13
+ ```
14
+
15
+ ### 2. Client Provides Directories
16
+
17
+ The client responds with file:// URIs representing directories it wants the server to have access to:
18
+
19
+ ```json
20
+ {
21
+ "roots": [
22
+ {
23
+ "uri": "file:///Users/dmitry.loktev/Projects/my-project",
24
+ "name": "My Project"
25
+ }
26
+ ]
27
+ }
28
+ ```
29
+
30
+ ### 3. Server Discovers Git Remotes
31
+
32
+ For each root directory, the server:
33
+ 1. Converts the file:// URI to a filesystem path
34
+ 2. Checks if it's a Git repository
35
+ 3. Runs `git remote get-url origin` to discover the remote URL
36
+ 4. Caches the discovered repository URLs
37
+
38
+ ### 4. Automatic Repository Selection
39
+
40
+ When you use the search tools without specifying a `repositoryGitRemoteUrl`, the server automatically uses the discovered repository.
41
+
42
+ ## Benefits
43
+
44
+ ### No Manual Configuration Required
45
+
46
+ Users don't need to set `REPOSITORY_GIT_REMOTE_URL` environment variable. The server automatically discovers repositories from the directories Claude Code is working with.
47
+
48
+ ### Multi-Repository Support
49
+
50
+ If the client provides multiple roots with different Git repositories, the server discovers all of them (currently uses the first one for searches).
51
+
52
+ ### Fallback to Environment Variable
53
+
54
+ If roots discovery fails or no roots are provided, the server falls back to `REPOSITORY_GIT_REMOTE_URL` if it's set.
55
+
56
+ ## Implementation Details
57
+
58
+ ### Git Discovery Module (`src/git-utils.ts`)
59
+
60
+ ```typescript
61
+ // Convert file:// URI to path
62
+ function uriToPath(uri: string): string | null
63
+
64
+ // Check if directory is a Git repository
65
+ function isGitRepository(directory: string): boolean
66
+
67
+ // Get Git remote URL from a directory
68
+ function getGitRemoteUrl(directory: string): string | null
69
+
70
+ // Discover all Git repositories from roots
71
+ function discoverRepositories(roots: Root[]): Repository[]
72
+ ```
73
+
74
+ ### Initialization Flow
75
+
76
+ 1. **Server connects** to transport (stdio)
77
+ 2. **Server calls** `initializeRepositories(server, config)`
78
+ 3. **Server requests** roots from client via `server.listRoots()`
79
+ 4. **Client responds** with list of root directories
80
+ 5. **Server discovers** Git remote URLs from each root
81
+ 6. **URLs are cached** for use in search operations
82
+
83
+ ### Tool Handlers
84
+
85
+ When you call `semantic_code_search` or `search_in_dependencies`:
86
+
87
+ ```typescript
88
+ // Priority order:
89
+ // 1. Explicit repositoryGitRemoteUrl in args
90
+ // 2. Discovered repository from roots
91
+ // 3. REPOSITORY_GIT_REMOTE_URL env variable
92
+ // 4. Error if none available
93
+
94
+ const repoUrl = repositoryGitRemoteUrl || getRepositoryUrl(config);
95
+ ```
96
+
97
+ ## Configuration
98
+
99
+ ### Claude Code (.mcp.json)
100
+
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "embark-mcp": {
105
+ "command": "node",
106
+ "args": ["/path/to/embark-remote-mcp/dist/index.js"],
107
+ "env": {
108
+ "ENABLE_LOCAL_LOGS": "true"
109
+ }
110
+ }
111
+ }
112
+ }
113
+ ```
114
+
115
+ Note: `REPOSITORY_GIT_REMOTE_URL` is now **optional**. The server will discover it automatically from the project directories Claude Code is working with.
116
+
117
+ ### Environment Variables
118
+
119
+ - `REPOSITORY_GIT_REMOTE_URL` (optional): Fallback repository URL if discovery fails
120
+ - `REPOSITORY_REVISION` (optional): Specific Git revision to search
121
+ - `ENABLE_LOCAL_LOGS` (optional): Enable logging to `~/.embark/debug.log`
122
+
123
+ ## Testing
124
+
125
+ ### Automated Test
126
+
127
+ ```bash
128
+ node test-git-discovery.mjs
129
+ ```
130
+
131
+ This test:
132
+ 1. Starts the server without `REPOSITORY_GIT_REMOTE_URL`
133
+ 2. Simulates a client providing roots
134
+ 3. Verifies the server discovers the Git remote URL
135
+ 4. Confirms searches use the discovered URL
136
+
137
+ ### Expected Output
138
+
139
+ ```
140
+ ============================================================
141
+ ✓ All tests passed!
142
+ ✓ Server successfully discovered Git repository from roots
143
+ ============================================================
144
+ ```
145
+
146
+ ### Manual Testing with Claude Code
147
+
148
+ 1. Open a Git repository in Claude Code
149
+ 2. The server will automatically discover the repository URL
150
+ 3. Check logs to see discovery in action:
151
+
152
+ ```bash
153
+ ./watch-logs.sh
154
+ ```
155
+
156
+ Look for these log entries:
157
+
158
+ ```json
159
+ {
160
+ "level": "info",
161
+ "message": "Requesting roots from client"
162
+ }
163
+ {
164
+ "level": "info",
165
+ "message": "Received roots from client",
166
+ "data": {
167
+ "roots": [
168
+ {
169
+ "uri": "file:///path/to/project",
170
+ "name": "Project"
171
+ }
172
+ ]
173
+ }
174
+ }
175
+ {
176
+ "level": "info",
177
+ "message": "Discovered git remote URL",
178
+ "data": {
179
+ "directory": "/path/to/project",
180
+ "url": "https://github.com/org/repo.git"
181
+ }
182
+ }
183
+ {
184
+ "level": "info",
185
+ "message": "Repository initialization complete",
186
+ "data": {
187
+ "repositoryCount": 1,
188
+ "repositories": [
189
+ {
190
+ "url": "https://github.com/org/repo.git",
191
+ "path": "/path/to/project"
192
+ }
193
+ ]
194
+ }
195
+ }
196
+ ```
197
+
198
+ ## Troubleshooting
199
+
200
+ ### No repositories discovered
201
+
202
+ **Problem**: Logs show "No Git repositories found in provided roots"
203
+
204
+ **Solutions**:
205
+ - Ensure the directory is a Git repository: `git remote -v`
206
+ - Check that Claude Code is opening the correct directory
207
+ - Verify the remote is named "origin": `git remote rename <name> origin`
208
+
209
+ ### Discovery fails but repository exists
210
+
211
+ **Problem**: Repository exists but isn't discovered
212
+
213
+ **Solutions**:
214
+ - Check file permissions on the `.git` directory
215
+ - Ensure `git` command is available in PATH
216
+ - Check logs for specific error messages
217
+
218
+ ### Server uses wrong repository
219
+
220
+ **Problem**: Multiple repositories but wrong one is selected
221
+
222
+ **Current behavior**: Server uses the first discovered repository
223
+
224
+ **Workaround**: Explicitly specify `repositoryGitRemoteUrl` in tool arguments
225
+
226
+ ## Future Enhancements
227
+
228
+ - Support for multiple repositories (let user choose which one to search)
229
+ - Watch for roots changes and re-discover repositories
230
+ - Support for other VCS systems (Mercurial, SVN)
231
+ - Cache Git discovery results across sessions