Skip to content

Commit 55faedb

Browse files
Fix suggestions v2
1 parent dc392e8 commit 55faedb

8 files changed

Lines changed: 64 additions & 7 deletions

File tree

agents/autogen/mcp_agent/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

agents/autogen/mcp_agent/main.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ class ChatRequest(BaseModel):
3636
"""Chat request: use `message` or `messages` (last user wins); set `stream` for SSE chunks."""
3737

3838
message: str | None = Field(
39-
None, description="Single user message (simplest). Ignored if `messages` is set."
39+
None,
40+
description="Single user message (simplest). Ignored if `messages` is set.",
4041
)
4142
messages: list[ChatMessage] | None = Field(
4243
None,
@@ -267,8 +268,8 @@ async def event_generator():
267268
return ChatResponse(messages=response_messages, finish_reason="stop")
268269
except Exception as e:
269270
raise HTTPException(
270-
status_code=500, detail=f"Error processing request: {str(e)}"
271-
)
271+
status_code=500, detail=f"Error processing request: {e!s}"
272+
) from e
272273

273274

274275
@app.get(
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,21 @@
11
MIT License
2+
3+
Copyright (c) 2026
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

agents/autogen/mcp_agent/mcp_automl_template/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Standard JSON Schema with `properties` and `required`. Field types and `required
117117
From the project root (or the directory containing `mcp_server.py`):
118118

119119
```bash
120-
python mcp_autoai_template/mcp_server.py
120+
python mcp_automl_template/mcp_server.py
121121
```
122122

123123
This starts the FastMCP server (e.g. SSE on `http://127.0.0.1:8000/sse`). Built-in tools (`add`, `sub`) and all tools from `tools_config.yaml` are registered.
@@ -127,7 +127,7 @@ This starts the FastMCP server (e.g. SSE on `http://127.0.0.1:8000/sse`). Built-
127127
With the MCP server running, in another terminal:
128128

129129
```bash
130-
python mcp_autoai_template/interact_with_mcp.py
130+
python mcp_automl_template/interact_with_mcp.py
131131
```
132132

133133
This connects to the server via SSE, loads MCP tools, and runs a LangGraph ReAct agent with the configured LLM. You can type questions or use predefined prompts. The agent will call tools (e.g. `invoke_churn`) when appropriate.

agents/autogen/mcp_agent/mcp_automl_template/k8s/deployment.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ spec:
2525
labels:
2626
app: mcp-automl
2727
spec:
28+
securityContext:
29+
runAsNonRoot: true
2830
containers:
2931
- name: mcp-automl
3032
image: "${CONTAINER_IMAGE_MCP}"
3133
ports:
3234
- containerPort: 8080
3335
name: http
36+
securityContext:
37+
allowPrivilegeEscalation: false
38+
capabilities:
39+
drop:
40+
- ALL
3441
env:
3542
- name: PORT
3643
value: "8080"

agents/autogen/mcp_agent/mcp_automl_template/mcp_server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@ def sub(a: int, b: int) -> int:
5050
if callable(fn):
5151
app = fn()
5252
break
53+
if app is None:
54+
raise RuntimeError(
55+
"FastMCP instance has no SSE app callable (sse_app or get_sse_app)"
56+
)
5357
port = int(getenv("PORT", 8000))
5458
uvicorn.run(app, host="0.0.0.0", port=port, forwarded_allow_ips="*")

agents/autogen/mcp_agent/mcp_automl_template/register_tools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def handler(**kwargs: Any) -> dict | str:
8585
res = httpx.post(
8686
url,
8787
json=data,
88-
verify=False,
88+
verify=True,
8989
follow_redirects=True,
9090
headers={"Authorization": f"Bearer {token}"},
9191
)

agents/autogen/mcp_agent/mcp_automl_template/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,12 @@ def get_chat_llama_stack():
159159
llama_api_key = getenv("LLAMA_STACK_CLIENT_API_KEY")
160160
model_id = getenv("MODEL_ID")
161161

162+
url = llama_base_url.rstrip("/") if llama_base_url else ""
163+
if not url.endswith("/v1"):
164+
url = url + "/v1"
165+
162166
return ChatLlamaStack(
163-
base_url=f"{llama_base_url}/v1",
167+
base_url=url,
164168
api_key=llama_api_key,
165169
model=model_id,
166170
temperature=0.1,

0 commit comments

Comments
 (0)