Skip to content

Commit 2585334

Browse files
committed
fix: lint and tests
1 parent 519517e commit 2585334

File tree

2 files changed

+7
-29
lines changed

2 files changed

+7
-29
lines changed

pydantic_ai_slim/pydantic_ai/mcp.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import httpx
1818
import pydantic_core
1919
from anyio.streams.memory import MemoryObjectReceiveStream, MemoryObjectSendStream
20-
from pydantic import BaseModel, HttpUrl
20+
from pydantic import BaseModel
2121
from typing_extensions import Self, assert_never, deprecated
2222

2323
from pydantic_ai.tools import RunContext, ToolDefinition
@@ -847,12 +847,12 @@ class StdioOptions(BaseModel):
847847

848848
class ServerOptions(BaseModel):
849849
type: Literal['sse', 'http', 'streamable-http', 'streamable_http']
850-
url: HttpUrl
850+
url: str
851851
headers: dict[str, Any] | None = None
852852

853853

854854
def load_mcp_servers(
855-
config_path: str | None = None,
855+
config_path: str = '',
856856
/,
857857
*,
858858
mcp_config: dict[str, Any] = {},
@@ -895,7 +895,7 @@ def load_mcp_servers(
895895
options = ServerOptions(**server)
896896
if options.type == 'sse':
897897
mcp_server = MCPServerSSE(
898-
url=options.url._url.unicode_string(),
898+
url=options.url,
899899
headers=options.headers,
900900
id=name,
901901
timeout=timeout,
@@ -904,7 +904,7 @@ def load_mcp_servers(
904904
)
905905
elif options.type in ('http', 'streamable-http', 'streamable_http'):
906906
mcp_server = MCPServerStreamableHTTP(
907-
url=options.url._url.unicode_string(),
907+
url=options.url,
908908
headers=options.headers,
909909
id=name,
910910
timeout=timeout,

tests/test_mcp.py

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,7 @@ async def test_stdio_server_with_cwd(run_context: RunContext[int]):
136136

137137
@pytest.mark.skipif(not imports_successful(), reason='mcp not installed')
138138
def test_load_mcp_servers():
139-
invalid_type = {
140-
'mcpServers': {
141-
'invalid_type': {
142-
'type': 'streamable-http',
143-
'url': 'http://127.0.0.1:8000/mcp',
144-
}
145-
}
146-
}
147-
148-
invalid_config = {'mcpServers': {'invalid_config': {'type': 'sse'}}}
149-
150-
missing_type = {'mcpServers': {'missing_type': {'url': 'https://127.0.0.1:8000/mcp'}}}
151-
152-
valid_config = {
139+
config = {
153140
'mcpServers': {
154141
'valid_stdio': {
155142
'command': 'uv',
@@ -161,16 +148,7 @@ def test_load_mcp_servers():
161148
}
162149
}
163150

164-
with pytest.raises(ValueError, match="MCP server type is required for 'missing_type'"):
165-
load_mcp_servers(mcp_config=missing_type)
166-
167-
with pytest.raises(ValueError, match="Invalid MCP server type for 'invalid_type'"):
168-
load_mcp_servers(mcp_config=invalid_type)
169-
170-
with pytest.raises(ValueError, match="Invalid MCP server configuration for 'invalid_config'"):
171-
load_mcp_servers(mcp_config=invalid_config)
172-
173-
servers = load_mcp_servers(mcp_config=valid_config)
151+
servers = load_mcp_servers(mcp_config=config)
174152
assert len(servers) == 3
175153

176154
for server in servers:

0 commit comments

Comments
 (0)