Skip to content

Commit

Permalink
remove MCP and add more http options
Browse files Browse the repository at this point in the history
  • Loading branch information
EItanya committed Jan 25, 2025
1 parent db763d5 commit 9c4a00b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 190 deletions.
9 changes: 5 additions & 4 deletions python/packages/autogen-ext/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,15 @@ semantic-kernel-dapr = [
"semantic-kernel[dapr]>=1.17.1",
]

http = [
"httpx>=0.27.0",
"json-schema-to-pydantic>=0.2.0"
]

semantic-kernel-all = [
"semantic-kernel[google,hugging_face,mistralai,ollama,onnx,anthropic,usearch,pandas,aws,dapr]>=1.17.1",
]

mcp = [
"mcp>=1.1.3",
"json-schema-to-pydantic>=0.2.0"
]
rich = ["rich>=13.9.4"]

[tool.hatch.build.targets.wheel]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
from typing import Any, Optional, Type
from typing import Any, Literal, Optional, Type

Check warning on line 1 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L1

Added line #L1 was not covered by tests

import httpx
from autogen_core import CancellationToken, Component
Expand All @@ -21,6 +20,10 @@ class HttpToolConfig(BaseModel):
"""

Check warning on line 20 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L19-L20

Added lines #L19 - L20 were not covered by tests
The URL to send the request to.
"""
method: Optional[Literal["GET", "POST", "PUT", "DELETE", "PATCH"]] = "POST"
"""

Check warning on line 24 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L23-L24

Added lines #L23 - L24 were not covered by tests
The HTTP method to use, will default to POST if not provided.
"""
headers: Optional[dict[str, Any]]
"""

Check warning on line 28 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L27-L28

Added lines #L27 - L28 were not covered by tests
A dictionary of headers to send with the request.
Expand Down Expand Up @@ -54,6 +57,15 @@ def __init__(self, server_params: HttpToolConfig) -> None:

super().__init__(input_model, return_type, name, description)

Check warning on line 58 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L58

Added line #L58 was not covered by tests

def _to_config(self) -> HttpToolConfig:
copied_config = self.server_params.copy()
return copied_config

Check warning on line 62 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L60-L62

Added lines #L60 - L62 were not covered by tests

@classmethod
def _from_config(cls, config: HttpToolConfig):
copied_config = config.model_copy().model_dump(exclude_none=True)
return cls(**copied_config)

Check warning on line 67 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L64-L67

Added lines #L64 - L67 were not covered by tests

async def run(self, args: BaseModel, cancellation_token: CancellationToken) -> Any:

Check warning on line 69 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L69

Added line #L69 was not covered by tests
"""Execute the MCP tool with the given arguments.
Expand All @@ -69,6 +81,16 @@ async def run(self, args: BaseModel, cancellation_token: CancellationToken) -> A
"""

async with httpx.AsyncClient() as client:
response = await client.post(self.server_params.url, json=args.model_dump())
match self.server_params.method:
case "GET":
response = await client.get(self.server_params.url, params=args.model_dump())
case "PUT":
response = await client.put(self.server_params.url, json=args.model_dump())
case "DELETE":
response = await client.delete(self.server_params.url, params=args.model_dump())
case "PATCH":
response = await client.patch(self.server_params.url, json=args.model_dump())
case _: # Default case
response = await client.post(self.server_params.url, json=args.model_dump())

Check warning on line 94 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L83-L94

Added lines #L83 - L94 were not covered by tests

return response.json()

Check warning on line 96 in python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py

View check run for this annotation

Codecov / codecov/patch

python/packages/autogen-ext/src/autogen_ext/tools/http/_http_tool.py#L96

Added line #L96 was not covered by tests

This file was deleted.

174 changes: 0 additions & 174 deletions python/packages/autogen-ext/src/autogen_ext/tools/mcp/_mcp_tool.py

This file was deleted.

12 changes: 6 additions & 6 deletions python/uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9c4a00b

Please sign in to comment.