diff --git a/portainer_stacks_server.py b/portainer_stacks_server.py index 9089955..917819d 100755 --- a/portainer_stacks_server.py +++ b/portainer_stacks_server.py @@ -568,29 +568,30 @@ async def handle_call_tool( elif name == "create_compose_stack_from_git": env_id = arguments["environment_id"] - # Build request data + # Build request data with lowercase field names for this endpoint data = { - "Name": arguments["name"], - "EndpointId": int(env_id), - "GitConfig": { - "URL": arguments["repository_url"], - "ReferenceName": arguments.get("repository_ref", "main"), - "ComposeFilePathInRepository": arguments.get("compose_path", "docker-compose.yml") - } + "name": arguments["name"], + "repositoryURL": arguments["repository_url"], + "repositoryReferenceName": arguments.get("repository_ref", "main"), + "composeFilePathInRepository": arguments.get("compose_path", "docker-compose.yml") } # Add authentication if provided if arguments.get("repository_auth") and arguments.get("repository_username"): - data["GitConfig"]["Authentication"] = { - "Username": arguments["repository_username"], - "Password": arguments.get("repository_password", "") - } + data["repositoryAuthentication"] = True + data["repositoryUsername"] = arguments["repository_username"] + data["repositoryPassword"] = arguments.get("repository_password", "") + else: + data["repositoryAuthentication"] = False # Add environment variables if provided if arguments.get("env_vars"): - data["Env"] = arguments["env_vars"] + data["env"] = arguments["env_vars"] - result = await make_request("POST", "/api/stacks", json_data=data) + # Use the correct endpoint for standalone Docker stack creation from Git + endpoint = f"/api/stacks/create/standalone/repository?endpointId={env_id}" + + result = await make_request("POST", endpoint, json_data=data) if "error" in result: return [types.TextContent(type="text", text=f"Error: {result['error']}")]