Repository navigation
Expand file tree
/
Copy pathserver.py
More file actions
161 lines (136 loc) · 4.89 KB
/
Copy pathserver.py
File metadata and controls
161 lines (136 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
from __future__ import annotations
from typing import Any
from mcp.server.fastmcp import FastMCP
from claude_codex_mcp.runtime import (
claude_ask as ask_claude,
claude_cancel as cancel_claude_job,
claude_continue as continue_claude_job,
claude_fix as fix_with_claude,
claude_result as read_claude_result,
claude_setup as inspect_claude_setup,
claude_status as read_claude_status,
claude_task as start_claude_task,
)
mcp = FastMCP(
"claude-code",
instructions=(
"Use these tools when the user asks Codex to call local Claude Code. "
"Use claude_ask for read-only questions, claude_fix for edits, and claude_continue "
"when the user says to continue. claude_task is the advanced interface. "
"Default model is claude-fable-5 and default effort is high."
),
)
@mcp.tool()
def claude_setup(workspace_path: str | None = None) -> dict[str, Any]:
"""Check whether Claude Code is installed and authenticated. Defaults to the current repository."""
return inspect_claude_setup(workspace_path)
@mcp.tool()
def claude_task(
prompt: str,
workspace_path: str | None = None,
write: bool = True,
background: bool = False,
model: str | None = "claude-fable-5",
effort: str | None = "high",
max_budget_usd: float | None = None,
timeout_seconds: float = 900,
new_conversation: bool = False,
resume_session_id: str | None = None,
) -> dict[str, Any]:
"""Run a Claude Code task. Defaults to the current repository, write=true, model=claude-fable-5, effort=high, and same-session resume."""
return start_claude_task(
prompt=prompt,
workspace_path=workspace_path,
write=write,
background=background,
model=model,
effort=effort,
max_budget_usd=max_budget_usd,
timeout_seconds=timeout_seconds,
new_conversation=new_conversation,
resume_session_id=resume_session_id,
)
@mcp.tool()
def claude_ask(
prompt: str,
workspace_path: str | None = None,
quick: bool = False,
background: bool = False,
model: str | None = "claude-fable-5",
effort: str | None = None,
max_budget_usd: float | None = None,
timeout_seconds: float = 900,
new_conversation: bool = False,
) -> dict[str, Any]:
"""Ask Claude Code a read-only question. Defaults to the current repository and same-session resume."""
return ask_claude(
prompt=prompt,
workspace_path=workspace_path,
quick=quick,
background=background,
model=model,
effort=effort,
max_budget_usd=max_budget_usd,
timeout_seconds=timeout_seconds,
new_conversation=new_conversation,
)
@mcp.tool()
def claude_fix(
prompt: str,
workspace_path: str | None = None,
background: bool = False,
model: str | None = "claude-fable-5",
effort: str | None = "high",
max_budget_usd: float | None = None,
timeout_seconds: float = 900,
new_conversation: bool = False,
) -> dict[str, Any]:
"""Ask Claude Code to edit files. Defaults to the current repository and same-session resume."""
return fix_with_claude(
prompt=prompt,
workspace_path=workspace_path,
background=background,
model=model,
effort=effort,
max_budget_usd=max_budget_usd,
timeout_seconds=timeout_seconds,
new_conversation=new_conversation,
)
@mcp.tool()
def claude_continue(
prompt: str,
workspace_path: str | None = None,
write: bool = True,
background: bool = False,
model: str | None = "claude-fable-5",
effort: str | None = "high",
max_budget_usd: float | None = None,
timeout_seconds: float = 900,
) -> dict[str, Any]:
"""Continue the latest Claude Code session recorded in this Codex session."""
return continue_claude_job(
prompt=prompt,
workspace_path=workspace_path,
write=write,
background=background,
model=model,
effort=effort,
max_budget_usd=max_budget_usd,
timeout_seconds=timeout_seconds,
)
@mcp.tool()
def claude_status(workspace_path: str | None = None, job_id: str | None = None, all: bool = False) -> dict[str, Any]:
"""Show running and recent Claude Code jobs for a workspace."""
return read_claude_status(workspace_path=workspace_path, job_id=job_id, all=all)
@mcp.tool()
def claude_result(workspace_path: str | None = None, job_id: str | None = None) -> dict[str, Any]:
"""Read a completed, failed, or cancelled Claude Code job."""
return read_claude_result(workspace_path=workspace_path, job_id=job_id)
@mcp.tool()
def claude_cancel(job_id: str, workspace_path: str | None = None) -> dict[str, Any]:
"""Cancel a running background Claude Code job. Defaults to the current repository."""
return cancel_claude_job(workspace_path=workspace_path, job_id=job_id)
def main() -> None:
mcp.run()
if __name__ == "__main__":
main()