fix linting issues with ruff

This commit is contained in:
Manoj Aggarwal 2026-01-13 13:57:04 -08:00
parent 063c272b98
commit 0c3e25a07b
4 changed files with 20 additions and 20 deletions

View file

@ -4,7 +4,6 @@ This module provides a client for communicating with MCP servers via stdio trans
It handles server lifecycle management, tool discovery, and tool execution.
"""
import asyncio
import logging
import os
from contextlib import asynccontextmanager
@ -54,15 +53,17 @@ class MCPClient:
)
# Spawn server process and create session
async with stdio_client(server=server_params) as (read, write):
async with ClientSession(read, write) as session:
# Initialize the connection
await session.initialize()
self.session = session
logger.info(
f"Connected to MCP server: {self.command} {' '.join(self.args)}"
)
yield session
async with (
stdio_client(server=server_params) as (read, write),
ClientSession(read, write) as session,
):
# Initialize the connection
await session.initialize()
self.session = session
logger.info(
f"Connected to MCP server: {self.command} {' '.join(self.args)}"
)
yield session
except Exception as e:
logger.error(f"Failed to connect to MCP server: {e!s}", exc_info=True)

View file

@ -59,7 +59,7 @@ def _normalize_gemini_params(params: dict[str, Any], mcp_schema: dict[str, Any])
normalized_item[item_key] = item_value
# Add missing required fields with empty defaults if needed
for required_field in items_properties.keys():
for required_field in items_properties:
if required_field not in normalized_item:
# For arrays like observations, default to empty array
if items_properties[required_field].get("type") == "array":
@ -102,6 +102,7 @@ def _create_dynamic_input_model_from_schema(
# Use Any type for complex schemas to preserve structure
# This allows the MCP server to do its own validation
from typing import Any as AnyType
from pydantic import Field
if is_required: