Merge branch 'main' into weather-server-rust
This commit is contained in:
commit
977b352510
4 changed files with 59 additions and 8 deletions
50
.github/workflows/claude.yml
vendored
Normal file
50
.github/workflows/claude.yml
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
name: Claude Code
|
||||||
|
|
||||||
|
on:
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
pull_request_review_comment:
|
||||||
|
types: [created]
|
||||||
|
issues:
|
||||||
|
types: [opened, assigned]
|
||||||
|
pull_request_review:
|
||||||
|
types: [submitted]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
claude:
|
||||||
|
if: |
|
||||||
|
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||||
|
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
|
||||||
|
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
|
||||||
|
(github.event_name == 'issues' && (contains(github.event.issue.body, '@claude') || contains(github.event.issue.title, '@claude')))
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
pull-requests: read
|
||||||
|
issues: read
|
||||||
|
id-token: write
|
||||||
|
actions: read # Required for Claude to read CI results on PRs
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Run Claude Code
|
||||||
|
id: claude
|
||||||
|
uses: anthropics/claude-code-action@v1
|
||||||
|
with:
|
||||||
|
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
|
|
||||||
|
# This is an optional setting that allows Claude to read CI results on PRs
|
||||||
|
additional_permissions: |
|
||||||
|
actions: read
|
||||||
|
|
||||||
|
# Optional: Give a custom prompt to Claude. If this is not specified, Claude will perform the instructions specified in the comment that tagged it.
|
||||||
|
# prompt: 'Update the pull request description to include a summary of changes.'
|
||||||
|
|
||||||
|
# Optional: Add claude_args to customize behavior and configuration
|
||||||
|
# See https://github.com/anthropics/claude-code-action/blob/main/docs/usage.md
|
||||||
|
# or https://docs.claude.com/en/docs/claude-code/cli-reference for available options
|
||||||
|
# claude_args: '--allowed-tools Bash(gh pr:*)'
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@ class MCPClient:
|
||||||
|
|
||||||
# Initial Claude API call
|
# Initial Claude API call
|
||||||
response = self.anthropic.messages.create(
|
response = self.anthropic.messages.create(
|
||||||
model="claude-3-5-sonnet-20241022",
|
model="claude-sonnet-4-0",
|
||||||
max_tokens=1000,
|
max_tokens=1000,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
tools=available_tools
|
tools=available_tools
|
||||||
|
|
@ -97,7 +97,7 @@ class MCPClient:
|
||||||
|
|
||||||
# Get next response from Claude
|
# Get next response from Claude
|
||||||
response = self.anthropic.messages.create(
|
response = self.anthropic.messages.create(
|
||||||
model="claude-3-5-sonnet-20241022",
|
model="claude-sonnet-4-0",
|
||||||
max_tokens=1000,
|
max_tokens=1000,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class MCPClient {
|
||||||
|
|
||||||
// Initial Claude API call
|
// Initial Claude API call
|
||||||
const response = await this.anthropic.messages.create({
|
const response = await this.anthropic.messages.create({
|
||||||
model: "claude-3-5-sonnet-20241022",
|
model: "claude-sonnet-4-0",
|
||||||
max_tokens: 1000,
|
max_tokens: 1000,
|
||||||
messages,
|
messages,
|
||||||
tools: this.tools,
|
tools: this.tools,
|
||||||
|
|
@ -100,7 +100,6 @@ class MCPClient {
|
||||||
|
|
||||||
// Process response and handle tool calls
|
// Process response and handle tool calls
|
||||||
const finalText = [];
|
const finalText = [];
|
||||||
const toolResults = [];
|
|
||||||
|
|
||||||
for (const content of response.content) {
|
for (const content of response.content) {
|
||||||
if (content.type === "text") {
|
if (content.type === "text") {
|
||||||
|
|
@ -114,7 +113,6 @@ class MCPClient {
|
||||||
name: toolName,
|
name: toolName,
|
||||||
arguments: toolArgs,
|
arguments: toolArgs,
|
||||||
});
|
});
|
||||||
toolResults.push(result);
|
|
||||||
finalText.push(
|
finalText.push(
|
||||||
`[Calling tool ${toolName} with args ${JSON.stringify(toolArgs)}]`,
|
`[Calling tool ${toolName} with args ${JSON.stringify(toolArgs)}]`,
|
||||||
);
|
);
|
||||||
|
|
@ -127,7 +125,7 @@ class MCPClient {
|
||||||
|
|
||||||
// Get next response from Claude
|
// Get next response from Claude
|
||||||
const response = await this.anthropic.messages.create({
|
const response = await this.anthropic.messages.create({
|
||||||
model: "claude-3-5-sonnet-20241022",
|
model: "claude-sonnet-4-0",
|
||||||
max_tokens: 1000,
|
max_tokens: 1000,
|
||||||
messages,
|
messages,
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,9 @@ Forecast: {period['detailedForecast']}
|
||||||
|
|
||||||
return "\n---\n".join(forecasts)
|
return "\n---\n".join(forecasts)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
# Initialize and run the server
|
# Initialize and run the server
|
||||||
mcp.run(transport='stdio')
|
mcp.run(transport='stdio')
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue