fast-agent-mcp 0.2.26__py3-none-any.whl → 0.2.28__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {fast_agent_mcp-0.2.26.dist-info → fast_agent_mcp-0.2.28.dist-info}/METADATA +4 -2
- {fast_agent_mcp-0.2.26.dist-info → fast_agent_mcp-0.2.28.dist-info}/RECORD +25 -20
- mcp_agent/agents/agent.py +1 -17
- mcp_agent/agents/base_agent.py +2 -0
- mcp_agent/config.py +3 -0
- mcp_agent/context.py +2 -0
- mcp_agent/core/agent_app.py +7 -2
- mcp_agent/core/interactive_prompt.py +58 -51
- mcp_agent/llm/augmented_llm_slow.py +42 -0
- mcp_agent/llm/model_factory.py +83 -40
- mcp_agent/llm/provider_types.py +4 -3
- mcp_agent/llm/providers/augmented_llm_google_native.py +459 -0
- mcp_agent/llm/providers/{augmented_llm_google.py → augmented_llm_google_oai.py} +2 -2
- mcp_agent/llm/providers/google_converter.py +361 -0
- mcp_agent/mcp/helpers/server_config_helpers.py +23 -0
- mcp_agent/mcp/mcp_agent_client_session.py +69 -24
- mcp_agent/mcp/mcp_aggregator.py +18 -3
- mcp_agent/mcp/mcp_connection_manager.py +6 -5
- mcp_agent/mcp/prompts/prompt_server.py +12 -4
- mcp_agent/mcp/sampling.py +40 -10
- mcp_agent/mcp_server_registry.py +15 -4
- mcp_agent/tools/tool_definition.py +14 -0
- {fast_agent_mcp-0.2.26.dist-info → fast_agent_mcp-0.2.28.dist-info}/WHEEL +0 -0
- {fast_agent_mcp-0.2.26.dist-info → fast_agent_mcp-0.2.28.dist-info}/entry_points.txt +0 -0
- {fast_agent_mcp-0.2.26.dist-info → fast_agent_mcp-0.2.28.dist-info}/licenses/LICENSE +0 -0
mcp_agent/mcp/sampling.py
CHANGED
@@ -10,6 +10,7 @@ from mcp.types import CreateMessageRequestParams, CreateMessageResult, TextConte
|
|
10
10
|
from mcp_agent.core.agent_types import AgentConfig
|
11
11
|
from mcp_agent.llm.sampling_converter import SamplingConverter
|
12
12
|
from mcp_agent.logging.logger import get_logger
|
13
|
+
from mcp_agent.mcp.helpers.server_config_helpers import get_server_config
|
13
14
|
from mcp_agent.mcp.interfaces import AugmentedLLMProtocol
|
14
15
|
|
15
16
|
if TYPE_CHECKING:
|
@@ -78,18 +79,47 @@ async def sample(mcp_ctx: ClientSession, params: CreateMessageRequestParams) ->
|
|
78
79
|
"""
|
79
80
|
model = None
|
80
81
|
try:
|
81
|
-
# Extract model from server config
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
)
|
89
|
-
|
82
|
+
# Extract model from server config using type-safe helper
|
83
|
+
server_config = get_server_config(mcp_ctx)
|
84
|
+
|
85
|
+
# First priority: explicitly configured sampling model
|
86
|
+
if server_config and hasattr(server_config, "sampling") and server_config.sampling:
|
87
|
+
model = server_config.sampling.model
|
88
|
+
|
89
|
+
# Second priority: auto_sampling fallback (if enabled at application level)
|
90
|
+
if model is None:
|
91
|
+
# Check if auto_sampling is enabled
|
92
|
+
auto_sampling_enabled = False
|
93
|
+
try:
|
94
|
+
from mcp_agent.context import get_current_context
|
95
|
+
app_context = get_current_context()
|
96
|
+
if app_context and app_context.config:
|
97
|
+
auto_sampling_enabled = getattr(app_context.config, 'auto_sampling', True)
|
98
|
+
except Exception as e:
|
99
|
+
logger.debug(f"Could not get application config: {e}")
|
100
|
+
auto_sampling_enabled = True # Default to enabled
|
101
|
+
|
102
|
+
if auto_sampling_enabled:
|
103
|
+
# Import here to avoid circular import
|
104
|
+
from mcp_agent.mcp.mcp_agent_client_session import MCPAgentClientSession
|
105
|
+
|
106
|
+
# Try agent's model first (from the session)
|
107
|
+
if (hasattr(mcp_ctx, 'session') and
|
108
|
+
isinstance(mcp_ctx.session, MCPAgentClientSession) and
|
109
|
+
mcp_ctx.session.agent_model):
|
110
|
+
model = mcp_ctx.session.agent_model
|
111
|
+
logger.debug(f"Using agent's model for sampling: {model}")
|
112
|
+
else:
|
113
|
+
# Fall back to system default model
|
114
|
+
try:
|
115
|
+
if app_context and app_context.config and app_context.config.default_model:
|
116
|
+
model = app_context.config.default_model
|
117
|
+
logger.debug(f"Using system default model for sampling: {model}")
|
118
|
+
except Exception as e:
|
119
|
+
logger.debug(f"Could not get system default model: {e}")
|
90
120
|
|
91
121
|
if model is None:
|
92
|
-
raise ValueError("No model configured")
|
122
|
+
raise ValueError("No model configured for sampling (server config, agent model, or system default)")
|
93
123
|
|
94
124
|
# Create an LLM instance
|
95
125
|
llm = create_sampling_llm(params, model)
|
mcp_agent/mcp_server_registry.py
CHANGED
@@ -70,9 +70,15 @@ class ServerRegistry:
|
|
70
70
|
config (Settings): The Settings object containing the server configurations.
|
71
71
|
config_path (str): Path to the YAML configuration file.
|
72
72
|
"""
|
73
|
-
|
74
|
-
self.load_registry_from_file(config_path)
|
75
|
-
)
|
73
|
+
if config is None:
|
74
|
+
self.registry = self.load_registry_from_file(config_path)
|
75
|
+
elif config.mcp is not None and hasattr(config.mcp, 'servers') and config.mcp.servers is not None:
|
76
|
+
# Ensure config.mcp exists, has a 'servers' attribute, and it's not None
|
77
|
+
self.registry = config.mcp.servers
|
78
|
+
else:
|
79
|
+
# Default to an empty dictionary if config.mcp is None or has no 'servers'
|
80
|
+
self.registry = {}
|
81
|
+
|
76
82
|
self.init_hooks: Dict[str, InitHookCallable] = {}
|
77
83
|
self.connection_manager = MCPConnectionManager(self)
|
78
84
|
|
@@ -88,8 +94,13 @@ class ServerRegistry:
|
|
88
94
|
Raises:
|
89
95
|
ValueError: If the configuration is invalid.
|
90
96
|
"""
|
97
|
+
servers = {}
|
91
98
|
|
92
|
-
|
99
|
+
settings = get_settings(config_path)
|
100
|
+
|
101
|
+
if settings.mcp is not None and hasattr(settings.mcp, 'servers') and settings.mcp.servers is not None:
|
102
|
+
return settings.mcp.servers
|
103
|
+
|
93
104
|
return servers
|
94
105
|
|
95
106
|
@asynccontextmanager
|
@@ -0,0 +1,14 @@
|
|
1
|
+
from dataclasses import dataclass, field
|
2
|
+
from typing import Any, Dict, Optional
|
3
|
+
|
4
|
+
|
5
|
+
@dataclass
|
6
|
+
class ToolDefinition:
|
7
|
+
"""
|
8
|
+
Represents a definition of a tool available to the agent.
|
9
|
+
"""
|
10
|
+
|
11
|
+
name: str
|
12
|
+
description: Optional[str] = None
|
13
|
+
inputSchema: Dict[str, Any] = field(default_factory=dict)
|
14
|
+
# Add other relevant fields if necessary based on how tools are defined in fast-agent
|
File without changes
|
File without changes
|
File without changes
|