Skip to content

Commit 3a9382d

Browse files
committed
Public release
0 parents  commit 3a9382d

22 files changed

+1873
-0
lines changed

.github/workflows/CI.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- main
6+
- master
7+
- release-*
8+
tags: '*'
9+
pull_request:
10+
jobs:
11+
test:
12+
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
fail-fast: false
16+
matrix:
17+
version:
18+
- '1'
19+
- 'pre'
20+
- 'nightly'
21+
os:
22+
- ubuntu-latest
23+
- macOS-latest
24+
arch:
25+
- x64
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: julia-actions/setup-julia@v2
29+
with:
30+
version: ${{ matrix.version }}
31+
arch: ${{ matrix.arch }}
32+
- uses: julia-actions/cache@v2
33+
- uses: julia-actions/julia-buildpkg@v1
34+
- uses: julia-actions/julia-runtest@v1
35+
- uses: julia-actions/julia-processcoverage@v1
36+
- uses: codecov/codecov-action@v4
37+
with:
38+
files: lcov.info
39+
token: ${{ secrets.CODECOV_TOKEN }}
40+
fail_ci_if_error: false

.github/workflows/CompatHelper.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: CompatHelper
2+
on:
3+
schedule:
4+
- cron: 0 0 * * *
5+
workflow_dispatch:
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
jobs:
10+
CompatHelper:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Pkg.add("CompatHelper")
14+
run: julia -e 'using Pkg; Pkg.add("CompatHelper")'
15+
- name: CompatHelper.main()
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
COMPATHELPER_PRIV: ${{ secrets.DOCUMENTER_KEY }}
19+
run: julia -e 'using CompatHelper; CompatHelper.main()'

.github/workflows/TagBot.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: TagBot
2+
on:
3+
issue_comment:
4+
types:
5+
- created
6+
workflow_dispatch:
7+
inputs:
8+
lookback:
9+
default: 3
10+
permissions:
11+
actions: read
12+
checks: read
13+
contents: write
14+
deployments: read
15+
issues: read
16+
discussions: read
17+
packages: read
18+
pages: read
19+
pull-requests: read
20+
repository-projects: read
21+
security-events: read
22+
statuses: read
23+
jobs:
24+
TagBot:
25+
if: github.event_name == 'workflow_dispatch' || github.actor == 'JuliaTagBot'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: JuliaRegistries/TagBot@v1
29+
with:
30+
token: ${{ secrets.GITHUB_TOKEN }}
31+
ssh: ${{ secrets.DOCUMENTER_KEY }}

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*.jl.cov
2+
*.jl.*.cov
3+
*.jl.mem
4+
/Manifest.toml
5+
/docs/Manifest.toml
6+
/docs/build/
7+
.DS_Store

CLAUDE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Development Guidelines for ClaudeMCPTools.jl
2+
3+
## Shipping Code
4+
5+
When asked to "ship it" or after making changes:
6+
7+
1. Stage all changes: `git add -A`
8+
2. Create a descriptive commit message
9+
3. Run tests locally and make sure they pass: `julia --project=. -e 'using Pkg; Pkg.test()'`
10+
4. Push to the repository: `git push origin master`
11+
5. **IMPORTANT**: Monitor the GitHub Actions CI run
12+
- Use: `gh run list --repo JuliaComputing/ClaudeMCPTools.jl --branch master --limit 1` to find the run
13+
- Use: `gh run watch <run-id> --repo JuliaComputing/ClaudeMCPTools.jl --exit-status` to monitor it (can take up to 10 minutes)
14+
- If it fails, investigate and fix before considering the task complete
15+
16+
## Testing
17+
18+
Always run tests before pushing:
19+
```bash
20+
julia --project=. -e 'using Pkg; Pkg.test()'
21+
```
22+
23+
## Package Structure
24+
25+
- `src/ClaudeMCPTools.jl` - Main module file
26+
- `src/types.jl` - Core types and interfaces
27+
- `src/server.jl` - MCP server implementation
28+
- `src/tools/` - Individual tool implementations
29+
- `bash.jl` - Bash command execution tool
30+
- `str_replace_editor.jl` - File editing tool
31+
32+
## Adding New Tools
33+
34+
1. Create a new file in `src/tools/`
35+
2. Define a struct that subtypes `MCPTool`
36+
3. Implement `tool_schema(tool)` method
37+
4. Implement `execute(tool, params)` method
38+
5. Export the tool from the main module
39+
6. Add tests in `test/`

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 The JuliaBench contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Project.toml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name = "ClaudeMCPTools"
2+
uuid = "b9bb1685-6a70-41d7-9793-2f9fb633d966"
3+
version = "0.1.0"
4+
authors = ["JuliaComputing"]
5+
6+
[deps]
7+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
8+
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
9+
10+
[extras]
11+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
12+
13+
[targets]
14+
test = ["Test"]

README.md

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# ClaudeMCPTools.jl
2+
3+
A Julia implementation of basic Model Context Protocol (MCP) tools for Claude and other AI assistants.
4+
5+
## Features
6+
7+
- **MCP Server**: Full implementation of the Model Context Protocol server
8+
- **Bash Tool**: Execute shell commands with proper stdout/stderr/exit code handling
9+
- **String Replace Editor Tool**: Edit files using string replacement operations
10+
- **Extensible Architecture**: Easy to add new tools by implementing the `MCPTool` interface
11+
12+
## Installation
13+
14+
```julia
15+
using Pkg
16+
Pkg.add(url="https://github.com/JuliaComputing/ClaudeMCPTools.jl")
17+
```
18+
19+
## Quick Start
20+
21+
```julia
22+
using ClaudeMCPTools
23+
24+
# Create an MCP server
25+
server = MCPServer(name="MyServer", version="1.0.0")
26+
27+
# Register tools
28+
register_tool!(server, "bash", BashTool())
29+
register_tool!(server, "editor", StrReplaceEditorTool())
30+
31+
# Run the server in stdio mode (for MCP communication)
32+
run_stdio_server(server)
33+
```
34+
35+
## Creating Custom Tools
36+
37+
To create a custom tool, implement the `MCPTool` interface:
38+
39+
```julia
40+
struct MyTool <: MCPTool
41+
# tool fields
42+
end
43+
44+
function tool_schema(tool::MyTool)
45+
return Dict(
46+
"name" => "my_tool",
47+
"description" => "Description of my tool",
48+
"inputSchema" => Dict(
49+
"type" => "object",
50+
"properties" => Dict(
51+
# Define parameters
52+
),
53+
"required" => [
54+
# List required parameters
55+
]
56+
)
57+
)
58+
end
59+
60+
function execute(tool::MyTool, params::Dict)
61+
# Implement tool logic
62+
# Return Dict("content" => [Dict("type" => "text", "text" => result)])
63+
end
64+
```
65+
66+
## Tools
67+
68+
### BashTool
69+
70+
Execute shell commands with full output capture:
71+
72+
```julia
73+
bash = BashTool(working_dir="/path/to/dir", env=Dict("VAR" => "value"))
74+
result = execute(bash, Dict("command" => "echo 'Hello World'"))
75+
```
76+
77+
### StrReplaceEditorTool
78+
79+
Edit files using string replacement:
80+
81+
```julia
82+
editor = StrReplaceEditorTool(base_path="/path/to/project")
83+
84+
# View a file
85+
execute(editor, Dict("command" => "view", "path" => "file.txt"))
86+
87+
# Replace text
88+
execute(editor, Dict(
89+
"command" => "str_replace",
90+
"path" => "file.txt",
91+
"old_str" => "old text",
92+
"new_str" => "new text"
93+
))
94+
95+
# Create a new file
96+
execute(editor, Dict(
97+
"command" => "create",
98+
"path" => "new_file.txt",
99+
"file_text" => "content"
100+
))
101+
```
102+
103+
## Protocol
104+
105+
ClaudeMCPTools.jl implements the Model Context Protocol version 2024-11-05, supporting:
106+
107+
- `initialize`: Initialize the server connection
108+
- `tools/list`: List available tools
109+
- `tools/call`: Execute a tool with parameters
110+
111+
## Testing
112+
113+
```julia
114+
using Pkg
115+
Pkg.test("ClaudeMCPTools")
116+
```
117+
118+
## License
119+
120+
MIT License
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# Str Replace Editor - Concise Response Format
2+
3+
## Summary
4+
5+
Updated the `str_replace_editor` tool in ClaudeMCPTools to use a concise response format. The tool no longer dumps the full file content in responses, making it cleaner and more efficient for LLM agents to use.
6+
7+
## Changes Made
8+
9+
### 1. **String Replacement Response**
10+
11+
**Before:**
12+
```
13+
Replaced 2 occurrence(s) in file.txt
14+
15+
>>> 5 Updated line here
16+
6 Context line
17+
7 Another line
18+
19+
>>> 12 Another updated line
20+
13 More context
21+
```
22+
23+
**After:**
24+
```
25+
The file file.txt has been edited successfully. Made 2 replacements.
26+
```
27+
28+
Or for single replacement:
29+
```
30+
The file file.txt has been edited successfully.
31+
```
32+
33+
### 2. **Create File Response**
34+
35+
**Before:**
36+
```
37+
Created file: test.txt
38+
39+
1 Line 1
40+
2 Line 2
41+
3 Line 3
42+
```
43+
44+
**After:**
45+
```
46+
File created successfully at test.txt
47+
```
48+
49+
### 3. **View Command Unchanged**
50+
51+
The `view` command still returns the full file content with line numbers, as this is its primary purpose and the agent expects to see the content.
52+
53+
## Benefits
54+
55+
1. **Cleaner Output**: Responses are concise and to the point
56+
2. **Less Token Usage**: Avoids repeating content the agent already knows
57+
3. **Consistent Format**: Consistent response format that agents expect
58+
4. **Faster Processing**: Less text to parse and process
59+
60+
## Testing
61+
62+
- Updated all test cases to match new response format
63+
- All 136 tests pass
64+
- Created test script `test_str_replace_responses.jl` to verify behavior
65+
66+
## Usage Example
67+
68+
```julia
69+
using ClaudeMCPTools
70+
71+
tool = StrReplaceEditorTool()
72+
73+
# Create a file
74+
result = execute(tool, Dict(
75+
"command" => "create",
76+
"path" => "example.txt",
77+
"file_text" => "Hello World"
78+
))
79+
# Returns: "File created successfully at example.txt"
80+
81+
# Edit the file
82+
result = execute(tool, Dict(
83+
"command" => "str_replace",
84+
"path" => "example.txt",
85+
"old_str" => "World",
86+
"new_str" => "Julia"
87+
))
88+
# Returns: "The file example.txt has been edited successfully."
89+
```
90+
91+
This change makes the tool more efficient and user-friendly for LLM agents.

0 commit comments

Comments
 (0)