Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite348d1e

Browse files
committed
require project directory
1 parent769a1eb commite348d1e

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

‎cli/exp_mcp.go

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,17 @@ func (*RootCmd) mcpConfigureClaudeCode() *serpent.Command {
111111
var (
112112
apiKeystring
113113
claudeConfigPathstring
114-
projectDirectorystring
115114
systemPromptstring
116-
taskPromptstring
117115
testBinaryNamestring
118116
)
119117
cmd:=&serpent.Command{
120-
Use:"claude-code",
121-
Short:"Configure the Claude Code server.",
118+
Use:"claude-code <project-directory>",
119+
Short:"Configure the Claude Code server. You will need to run this command for each project you want to use. Specify the project directory as the first argument.",
122120
Handler:func(inv*serpent.Invocation)error {
121+
iflen(inv.Args)==0 {
122+
returnxerrors.Errorf("project directory is required")
123+
}
124+
projectDirectory:=inv.Args[0]
123125
fs:=afero.NewOsFs()
124126
binPath,err:=os.Executable()
125127
iferr!=nil {
@@ -174,20 +176,6 @@ func (*RootCmd) mcpConfigureClaudeCode() *serpent.Command {
174176
Flag:"claude-system-prompt",
175177
Value:serpent.StringOf(&systemPrompt),
176178
},
177-
{
178-
Name:"task-prompt",
179-
Description:"The task prompt to use for the Claude Code server.",
180-
Env:"CODER_MCP_CLAUDE_TASK_PROMPT",
181-
Flag:"claude-task-prompt",
182-
Value:serpent.StringOf(&taskPrompt),
183-
},
184-
{
185-
Name:"project-directory",
186-
Description:"The project directory to use for the Claude Code server.",
187-
Env:"CODER_MCP_CLAUDE_PROJECT_DIRECTORY",
188-
Flag:"claude-project-directory",
189-
Value:serpent.StringOf(&projectDirectory),
190-
},
191179
{
192180
Name:"test-binary-name",
193181
Description:"Only used for testing.",
@@ -428,7 +416,7 @@ func configureClaude(fs afero.Fs, cfg ClaudeConfig) error {
428416
returnxerrors.Errorf("failed to stat claude config: %w",err)
429417
}
430418
// Touch the file to create it if it doesn't exist.
431-
iferr=afero.WriteFile(fs,cfg.ConfigPath, []byte(`{}`),0600);err!=nil {
419+
iferr=afero.WriteFile(fs,cfg.ConfigPath, []byte(`{}`),0o600);err!=nil {
432420
returnxerrors.Errorf("failed to touch claude config: %w",err)
433421
}
434422
}
@@ -513,7 +501,7 @@ func configureClaude(fs afero.Fs, cfg ClaudeConfig) error {
513501
iferr!=nil {
514502
returnxerrors.Errorf("failed to marshal claude config: %w",err)
515503
}
516-
err=afero.WriteFile(fs,cfg.ConfigPath,newConfigBytes,0644)
504+
err=afero.WriteFile(fs,cfg.ConfigPath,newConfigBytes,0o644)
517505
iferr!=nil {
518506
returnxerrors.Errorf("failed to write claude config: %w",err)
519507
}

‎cli/exp_mcp_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,18 @@ func TestExpMcpServer(t *testing.T) {
143143
})
144144
}
145145

146-
funcTestExpMcpConfigure(t*testing.T) {
147-
t.Run("ClaudeCode",func(t*testing.T) {
146+
//nolint:tparallel,paralleltest
147+
funcTestExpMcpConfigureClaudeCode(t*testing.T) {
148+
t.Run("NoProjectDirectory",func(t*testing.T) {
149+
ctx:=testutil.Context(t,testutil.WaitShort)
150+
cancelCtx,cancel:=context.WithCancel(ctx)
151+
t.Cleanup(cancel)
152+
153+
inv,_:=clitest.New(t,"exp","mcp","configure","claude-code")
154+
err:=inv.WithContext(cancelCtx).Run()
155+
require.ErrorContains(t,err,"project directory is required")
156+
})
157+
t.Run("NewConfig",func(t*testing.T) {
148158
t.Setenv("CODER_AGENT_TOKEN","test-agent-token")
149159
ctx:=testutil.Context(t,testutil.WaitShort)
150160
cancelCtx,cancel:=context.WithCancel(ctx)
@@ -182,12 +192,10 @@ func TestExpMcpConfigure(t *testing.T) {
182192
}
183193
}`
184194

185-
inv,root:=clitest.New(t,"exp","mcp","configure","claude-code",
195+
inv,root:=clitest.New(t,"exp","mcp","configure","claude-code","/path/to/project",
186196
"--claude-api-key=test-api-key",
187197
"--claude-config-path="+claudeConfigPath,
188-
"--claude-project-directory=/path/to/project",
189198
"--claude-system-prompt=test-system-prompt",
190-
"--claude-task-prompt=test-task-prompt",
191199
"--claude-test-binary-name=pathtothecoderbinary",
192200
)
193201
clitest.SetupConfig(t,client,root)
@@ -246,12 +254,10 @@ func TestExpMcpConfigure(t *testing.T) {
246254
}
247255
}`
248256

249-
inv,root:=clitest.New(t,"exp","mcp","configure","claude-code",
257+
inv,root:=clitest.New(t,"exp","mcp","configure","claude-code","/path/to/project",
250258
"--claude-api-key=test-api-key",
251259
"--claude-config-path="+claudeConfigPath,
252-
"--claude-project-directory=/path/to/project",
253260
"--claude-system-prompt=test-system-prompt",
254-
"--claude-task-prompt=test-task-prompt",
255261
"--claude-test-binary-name=pathtothecoderbinary",
256262
)
257263

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp