Update README.md
This commit is contained in:
97
deploy_with_claude_api.py
Normal file
97
deploy_with_claude_api.py
Normal file
@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Script to deploy the Nomad MCP service using the Claude API.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import requests
|
||||
from dotenv import load_dotenv
|
||||
|
||||
# Load environment variables from .env file
|
||||
load_dotenv()
|
||||
|
||||
def main():
|
||||
print("Deploying Nomad MCP service using the Claude API...")
|
||||
|
||||
# Define the API endpoint
|
||||
api_url = "http://localhost:8000/api/claude/create-job"
|
||||
|
||||
# Create the job specification for the Claude API
|
||||
job_spec = {
|
||||
"job_id": "nomad-mcp",
|
||||
"name": "Nomad MCP Service",
|
||||
"type": "service",
|
||||
"datacenters": ["jm"],
|
||||
"namespace": "development",
|
||||
"docker_image": "registry.dev.meisheng.group/nomad_mcp:20250226",
|
||||
"count": 1,
|
||||
"cpu": 200,
|
||||
"memory": 256,
|
||||
"ports": [
|
||||
{
|
||||
"Label": "http",
|
||||
"Value": 0,
|
||||
"To": 8000
|
||||
}
|
||||
],
|
||||
"env_vars": {
|
||||
"NOMAD_ADDR": "http://pjmldk01.ds.meisheng.group:4646",
|
||||
"NOMAD_NAMESPACE": "development",
|
||||
"NOMAD_SKIP_VERIFY": "true",
|
||||
"PORT": "8000",
|
||||
"HOST": "0.0.0.0",
|
||||
"LOG_LEVEL": "INFO",
|
||||
"RELOAD": "true"
|
||||
},
|
||||
# Note: The Claude API doesn't directly support command and args,
|
||||
# so we'll need to add a note about this limitation
|
||||
}
|
||||
|
||||
try:
|
||||
# Make the API request
|
||||
print("Sending request to Claude API...")
|
||||
response = requests.post(
|
||||
api_url,
|
||||
json=job_spec,
|
||||
headers={"Content-Type": "application/json"}
|
||||
)
|
||||
|
||||
# Check if the request was successful
|
||||
if response.status_code == 200:
|
||||
result = response.json()
|
||||
print("\nJob registration response:")
|
||||
print(json.dumps(result, indent=2))
|
||||
|
||||
if result.get("success"):
|
||||
print("\n✅ Nomad MCP service deployed successfully!")
|
||||
print(f"Job ID: {result.get('job_id')}")
|
||||
print(f"Status: {result.get('status')}")
|
||||
print("\nThe service will be available at: https://nomad_mcp.dev.meisheng.group")
|
||||
|
||||
# Add Traefik configuration and command information
|
||||
print("\nImportant Notes:")
|
||||
print("1. The Claude API doesn't directly support adding Traefik tags.")
|
||||
print(" You may need to update the job manually to add the following tags:")
|
||||
print(" - traefik.enable=true")
|
||||
print(" - traefik.http.routers.nomad-mcp.entryPoints=https")
|
||||
print(" - traefik.http.routers.nomad-mcp.rule=Host(`nomad_mcp.dev.meisheng.group`)")
|
||||
print(" - traefik.http.routers.nomad-mcp.middlewares=proxyheaders@consulcatalog")
|
||||
print("\n2. The Claude API doesn't directly support specifying command and args.")
|
||||
print(" You need to update the job manually to add the following:")
|
||||
print(" - command: python")
|
||||
print(" - args: [\"-m\", \"uvicorn\", \"app.main:app\", \"--host\", \"0.0.0.0\", \"--port\", \"8000\"]")
|
||||
else:
|
||||
print("\n❌ Failed to deploy Nomad MCP service.")
|
||||
print(f"Message: {result.get('message', 'Unknown error')}")
|
||||
else:
|
||||
print(f"\n❌ API request failed with status code: {response.status_code}")
|
||||
print(f"Response: {response.text}")
|
||||
|
||||
except Exception as e:
|
||||
print(f"Error deploying Nomad MCP service: {str(e)}")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user