fast-agent-mcp 0.1.9__tar.gz → 0.1.10__tar.gz
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.1.9 → fast_agent_mcp-0.1.10}/PKG-INFO +4 -3
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/README.md +3 -2
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/pyproject.toml +1 -1
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/agents/agent.py +112 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/context.py +0 -2
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/factory.py +14 -13
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/fastagent.py +2 -2
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/proxies.py +38 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/logging/listeners.py +3 -6
- fast_agent_mcp-0.1.10/src/mcp_agent/mcp/mcp_agent_client_session.py +118 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/mcp_aggregator.py +50 -2
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/mcp_connection_manager.py +0 -1
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/prompts/prompt_server.py +12 -11
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/resource_utils.py +58 -38
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/stdio.py +23 -15
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp_server_registry.py +5 -2
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/orchestrator.py +3 -3
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/augmented_llm_passthrough.py +57 -2
- fast_agent_mcp-0.1.9/src/mcp_agent/mcp/mcp_agent_client_session.py +0 -242
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/.gitignore +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/LICENSE +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/agents/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/app.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/cli/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/cli/__main__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/cli/commands/bootstrap.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/cli/commands/config.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/cli/commands/setup.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/cli/main.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/cli/terminal.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/config.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/console.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/context_dependent.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/agent_app.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/agent_types.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/agent_utils.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/decorators.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/enhanced_prompt.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/error_handling.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/exceptions.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/mcp_content.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/prompt.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/types.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/core/validation.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/eval/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/event_progress.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/executor/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/executor/decorator_registry.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/executor/executor.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/executor/task_registry.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/executor/temporal.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/executor/workflow.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/executor/workflow_signal.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/human_input/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/human_input/handler.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/human_input/types.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/logging/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/logging/events.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/logging/json_serializer.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/logging/logger.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/logging/rich_progress.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/logging/tracing.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/logging/transport.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/gen_client.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/mcp_activity.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/mcp_agent_server.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/mime_utils.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/prompt_message_multipart.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/prompt_serialization.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/prompts/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/prompts/__main__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp/prompts/prompt_template.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp_server/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/mcp_server/agent_server.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/progress_display.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/data-analysis/analysis-campaign.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/data-analysis/analysis.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/data-analysis/fastagent.config.yaml +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/internal/agent.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/internal/fastagent.config.yaml +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/internal/job.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/internal/prompt_category.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/internal/prompt_sizing.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/internal/sizer.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/internal/social.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/mcp_researcher/researcher-eval.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/prompting/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/prompting/agent.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/prompting/fastagent.config.yaml +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/prompting/image_server.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/researcher/fastagent.config.yaml +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/researcher/researcher-eval.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/researcher/researcher-imp.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/researcher/researcher.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/agent_build.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/chaining.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/evaluator.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/fastagent.config.yaml +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/human_input.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/parallel.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/router.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/resources/examples/workflows/sse.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/telemetry/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/telemetry/usage_tracking.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/ui/console_display.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/embedding/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/embedding/embedding_base.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/embedding/embedding_cohere.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/embedding/embedding_openai.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/evaluator_optimizer/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/evaluator_optimizer/evaluator_optimizer.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/intent_classifier/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/intent_classifier/intent_classifier_base.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/intent_classifier/intent_classifier_embedding.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/intent_classifier/intent_classifier_embedding_cohere.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/intent_classifier/intent_classifier_embedding_openai.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/intent_classifier/intent_classifier_llm.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/intent_classifier/intent_classifier_llm_anthropic.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/intent_classifier/intent_classifier_llm_openai.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/anthropic_utils.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/augmented_llm.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/augmented_llm_anthropic.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/augmented_llm_openai.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/augmented_llm_playback.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/llm_selector.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/model_factory.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/openai_utils.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/prompt_utils.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/providers/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/providers/multipart_converter_anthropic.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/providers/multipart_converter_openai.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/providers/openai_multipart.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/providers/sampling_converter_anthropic.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/providers/sampling_converter_openai.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/llm/sampling_format_converter.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/orchestrator/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/orchestrator/orchestrator.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/orchestrator/orchestrator_models.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/orchestrator/orchestrator_prompts.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/parallel/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/parallel/fan_in.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/parallel/fan_out.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/parallel/parallel_llm.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/router/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/router/router_base.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/router/router_embedding.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/router/router_embedding_cohere.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/router/router_embedding_openai.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/router/router_llm.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/swarm/__init__.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/swarm/swarm.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/swarm/swarm_anthropic.py +0 -0
- {fast_agent_mcp-0.1.9 → fast_agent_mcp-0.1.10}/src/mcp_agent/workflows/swarm/swarm_openai.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: fast-agent-mcp
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.10
|
4
4
|
Summary: Define, Prompt and Test MCP enabled Agents and Workflows
|
5
5
|
Author-email: Shaun Smith <fastagent@llmindset.co.uk>, Sarmad Qadri <sarmad@lastmileai.dev>
|
6
6
|
License: Apache License
|
@@ -259,9 +259,10 @@ The simple declarative syntax lets you concentrate on composing your Prompts and
|
|
259
259
|
|
260
260
|
Evaluate how different models handle Agent and MCP Server calling tasks, then build multi-model workflows using the best provider for each task.
|
261
261
|
|
262
|
-
`fast-agent` is now multi-modal, supporting Images and PDFs for both Anthropic and OpenAI endpoints (for supported models), via Prompts and MCP Tool Call results.
|
262
|
+
`fast-agent` is now multi-modal, supporting Images and PDFs for both Anthropic and OpenAI endpoints (for supported models), via Prompts, Resources and MCP Tool Call results.
|
263
263
|
|
264
|
-
> [!TIP]
|
264
|
+
> [!TIP]
|
265
|
+
> `fast-agent` is now MCP Native! Coming Soon - Full Documentation Site.
|
265
266
|
|
266
267
|
### Agent Application Development
|
267
268
|
|
@@ -16,9 +16,10 @@ The simple declarative syntax lets you concentrate on composing your Prompts and
|
|
16
16
|
|
17
17
|
Evaluate how different models handle Agent and MCP Server calling tasks, then build multi-model workflows using the best provider for each task.
|
18
18
|
|
19
|
-
`fast-agent` is now multi-modal, supporting Images and PDFs for both Anthropic and OpenAI endpoints (for supported models), via Prompts and MCP Tool Call results.
|
19
|
+
`fast-agent` is now multi-modal, supporting Images and PDFs for both Anthropic and OpenAI endpoints (for supported models), via Prompts, Resources and MCP Tool Call results.
|
20
20
|
|
21
|
-
> [!TIP]
|
21
|
+
> [!TIP]
|
22
|
+
> `fast-agent` is now MCP Native! Coming Soon - Full Documentation Site.
|
22
23
|
|
23
24
|
### Agent Application Development
|
24
25
|
|
@@ -9,7 +9,10 @@ from mcp.types import (
|
|
9
9
|
ListToolsResult,
|
10
10
|
TextContent,
|
11
11
|
Tool,
|
12
|
+
EmbeddedResource,
|
13
|
+
ReadResourceResult,
|
12
14
|
)
|
15
|
+
from mcp_agent.mcp.prompt_message_multipart import PromptMessageMultipart
|
13
16
|
|
14
17
|
from mcp_agent.core.exceptions import PromptExitError
|
15
18
|
from mcp_agent.mcp.mcp_aggregator import MCPAggregator
|
@@ -320,6 +323,11 @@ class Agent(MCPAggregator):
|
|
320
323
|
],
|
321
324
|
)
|
322
325
|
|
326
|
+
async def read_resource(
|
327
|
+
self, server_name: str, resource_name: str
|
328
|
+
) -> ReadResourceResult:
|
329
|
+
return None
|
330
|
+
|
323
331
|
async def apply_prompt(
|
324
332
|
self, prompt_name: str, arguments: dict[str, str] = None
|
325
333
|
) -> str:
|
@@ -359,3 +367,107 @@ class Agent(MCPAggregator):
|
|
359
367
|
# The LLM will automatically generate a response if needed
|
360
368
|
result = await self._llm.apply_prompt_template(prompt_result, display_name)
|
361
369
|
return result
|
370
|
+
|
371
|
+
async def get_resource(self, server_name: str, resource_name: str):
|
372
|
+
"""
|
373
|
+
Get a resource directly from an MCP server by name.
|
374
|
+
|
375
|
+
Args:
|
376
|
+
server_name: Name of the MCP server to retrieve the resource from
|
377
|
+
resource_name: Name of the resource to retrieve
|
378
|
+
|
379
|
+
Returns:
|
380
|
+
The resource object from the MCP server
|
381
|
+
|
382
|
+
Raises:
|
383
|
+
ValueError: If the server doesn't exist or the resource couldn't be found
|
384
|
+
"""
|
385
|
+
if not self.initialized:
|
386
|
+
await self.initialize()
|
387
|
+
|
388
|
+
# Get the specified server connection
|
389
|
+
server = self.get_server(server_name)
|
390
|
+
if not server:
|
391
|
+
raise ValueError(f"Server '{server_name}' not found or not connected")
|
392
|
+
|
393
|
+
# Request the resource directly from the server
|
394
|
+
try:
|
395
|
+
resource_result = await server.get_resource(resource_name)
|
396
|
+
return resource_result
|
397
|
+
except Exception as e:
|
398
|
+
self.logger.error(
|
399
|
+
f"Error retrieving resource '{resource_name}' from server '{server_name}': {str(e)}"
|
400
|
+
)
|
401
|
+
raise ValueError(
|
402
|
+
f"Failed to retrieve resource '{resource_name}' from server '{server_name}': {str(e)}"
|
403
|
+
)
|
404
|
+
|
405
|
+
async def get_embedded_resources(
|
406
|
+
self, server_name: str, resource_name: str
|
407
|
+
) -> List[EmbeddedResource]:
|
408
|
+
"""
|
409
|
+
Get a resource from an MCP server and return it as a list of embedded resources ready for use in prompts.
|
410
|
+
|
411
|
+
Args:
|
412
|
+
server_name: Name of the MCP server to retrieve the resource from
|
413
|
+
resource_name: Name or URI of the resource to retrieve
|
414
|
+
|
415
|
+
Returns:
|
416
|
+
List of EmbeddedResource objects ready to use in a PromptMessageMultipart
|
417
|
+
|
418
|
+
Raises:
|
419
|
+
ValueError: If the server doesn't exist or the resource couldn't be found
|
420
|
+
"""
|
421
|
+
# Get the raw resource result
|
422
|
+
result: ReadResourceResult = await super().get_resource(
|
423
|
+
server_name, resource_name
|
424
|
+
)
|
425
|
+
|
426
|
+
# Convert each resource content to an EmbeddedResource
|
427
|
+
embedded_resources: List[EmbeddedResource] = []
|
428
|
+
for resource_content in result.contents:
|
429
|
+
embedded_resource = EmbeddedResource(
|
430
|
+
type="resource", resource=resource_content, annotations=None
|
431
|
+
)
|
432
|
+
embedded_resources.append(embedded_resource)
|
433
|
+
|
434
|
+
return embedded_resources
|
435
|
+
|
436
|
+
async def with_resource(
|
437
|
+
self,
|
438
|
+
prompt_content: Union[str, PromptMessageMultipart],
|
439
|
+
server_name: str,
|
440
|
+
resource_name: str,
|
441
|
+
) -> str:
|
442
|
+
"""
|
443
|
+
Create a prompt with the given content and resource, then send it to the agent.
|
444
|
+
|
445
|
+
Args:
|
446
|
+
prompt_content: Either a string message or an existing PromptMessageMultipart
|
447
|
+
server_name: Name of the MCP server to retrieve the resource from
|
448
|
+
resource_name: Name or URI of the resource to retrieve
|
449
|
+
|
450
|
+
Returns:
|
451
|
+
The agent's response as a string
|
452
|
+
"""
|
453
|
+
# Get the embedded resources
|
454
|
+
embedded_resources: List[EmbeddedResource] = await self.get_embedded_resources(
|
455
|
+
server_name, resource_name
|
456
|
+
)
|
457
|
+
|
458
|
+
# Create or update the prompt message
|
459
|
+
prompt: PromptMessageMultipart
|
460
|
+
if isinstance(prompt_content, str):
|
461
|
+
# Create a new prompt with the text and resources
|
462
|
+
content = [TextContent(type="text", text=prompt_content)]
|
463
|
+
content.extend(embedded_resources)
|
464
|
+
prompt = PromptMessageMultipart(role="user", content=content)
|
465
|
+
elif isinstance(prompt_content, PromptMessageMultipart):
|
466
|
+
# Add resources to the existing prompt
|
467
|
+
prompt = prompt_content
|
468
|
+
prompt.content.extend(embedded_resources)
|
469
|
+
else:
|
470
|
+
raise TypeError("prompt_content must be a string or PromptMessageMultipart")
|
471
|
+
|
472
|
+
# Send the prompt to the agent and return the response
|
473
|
+
return await self._llm.generate_prompt(prompt, None)
|
@@ -24,7 +24,6 @@ from mcp_agent.executor.executor import Executor
|
|
24
24
|
from mcp_agent.executor.decorator_registry import (
|
25
25
|
DecoratorRegistry,
|
26
26
|
register_asyncio_decorators,
|
27
|
-
register_temporal_decorators,
|
28
27
|
)
|
29
28
|
from mcp_agent.executor.task_registry import ActivityRegistry
|
30
29
|
from mcp_agent.executor.executor import AsyncioExecutor
|
@@ -194,7 +193,6 @@ async def initialize_context(
|
|
194
193
|
|
195
194
|
context.decorator_registry = DecoratorRegistry()
|
196
195
|
register_asyncio_decorators(context.decorator_registry)
|
197
|
-
register_temporal_decorators(context.decorator_registry)
|
198
196
|
|
199
197
|
# Store the tracer in context if needed
|
200
198
|
context.tracer = trace.get_tracer(config.otel.service_name)
|
@@ -172,16 +172,17 @@ async def create_agents_by_type(
|
|
172
172
|
if agent_type == AgentType.BASIC:
|
173
173
|
# Get the agent name for special handling
|
174
174
|
agent_name = agent_data["config"].name
|
175
|
-
agent = Agent(
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
model=config.model,
|
181
|
-
request_params=config.default_request_params,
|
182
|
-
)
|
183
|
-
agent._llm = await agent.attach_llm(llm_factory)
|
175
|
+
agent = Agent(
|
176
|
+
config=config,
|
177
|
+
context=app_instance.context,
|
178
|
+
)
|
179
|
+
await agent.initialize()
|
184
180
|
|
181
|
+
llm_factory = model_factory_func(
|
182
|
+
model=config.model,
|
183
|
+
request_params=config.default_request_params,
|
184
|
+
)
|
185
|
+
agent._llm = await agent.attach_llm(llm_factory)
|
185
186
|
# Store the agent
|
186
187
|
instance = agent
|
187
188
|
|
@@ -222,16 +223,16 @@ async def create_agents_by_type(
|
|
222
223
|
default_request_params=base_params,
|
223
224
|
)
|
224
225
|
planner_agent = Agent(
|
225
|
-
config=planner_config,
|
226
|
+
config=planner_config,
|
227
|
+
context=app_instance.context,
|
226
228
|
)
|
227
229
|
planner_factory = model_factory_func(
|
228
230
|
model=config.model,
|
229
231
|
request_params=config.default_request_params,
|
230
232
|
)
|
231
233
|
|
232
|
-
|
233
|
-
|
234
|
-
|
234
|
+
planner = await planner_agent.attach_llm(planner_factory)
|
235
|
+
await planner.initialize()
|
235
236
|
# Create the orchestrator with pre-configured planner
|
236
237
|
instance = Orchestrator(
|
237
238
|
name=config.name,
|
@@ -16,7 +16,6 @@ from contextlib import asynccontextmanager
|
|
16
16
|
from functools import partial
|
17
17
|
|
18
18
|
from mcp_agent.app import MCPApp
|
19
|
-
from mcp_agent.context_dependent import ContextDependent
|
20
19
|
from mcp_agent.config import Settings
|
21
20
|
|
22
21
|
from mcp_agent.core.agent_app import AgentApp
|
@@ -64,7 +63,7 @@ from mcp_agent.mcp_server import AgentMCPServer
|
|
64
63
|
T = TypeVar("T") # For the wrapper classes
|
65
64
|
|
66
65
|
|
67
|
-
class FastAgent
|
66
|
+
class FastAgent:
|
68
67
|
"""
|
69
68
|
A decorator-based interface for MCP Agent applications.
|
70
69
|
Provides a simplified way to create and manage agents using decorators.
|
@@ -320,6 +319,7 @@ class FastAgent(ContextDependent):
|
|
320
319
|
"""
|
321
320
|
active_agents = {}
|
322
321
|
had_error = False
|
322
|
+
await self.app.initialize()
|
323
323
|
|
324
324
|
# Handle quiet mode by disabling logger settings after initialization
|
325
325
|
quiet_mode = hasattr(self, "args") and self.args.quiet
|
@@ -8,6 +8,7 @@ from typing import List, Optional, Dict, Union, TYPE_CHECKING
|
|
8
8
|
from mcp_agent.agents.agent import Agent
|
9
9
|
from mcp_agent.app import MCPApp
|
10
10
|
from mcp_agent.mcp.prompt_message_multipart import PromptMessageMultipart
|
11
|
+
from mcp.types import EmbeddedResource
|
11
12
|
|
12
13
|
# Handle circular imports
|
13
14
|
if TYPE_CHECKING:
|
@@ -129,6 +130,43 @@ class LLMAgentProxy(BaseAgentProxy):
|
|
129
130
|
"""
|
130
131
|
return await self._agent.apply_prompt(prompt_name, arguments)
|
131
132
|
|
133
|
+
# Add the new methods
|
134
|
+
async def get_embedded_resources(
|
135
|
+
self, server_name: str, resource_name: str
|
136
|
+
) -> List[EmbeddedResource]:
|
137
|
+
"""
|
138
|
+
Get a resource from an MCP server and return it as a list of embedded resources ready for use in prompts.
|
139
|
+
|
140
|
+
Args:
|
141
|
+
server_name: Name of the MCP server to retrieve the resource from
|
142
|
+
resource_name: Name or URI of the resource to retrieve
|
143
|
+
|
144
|
+
Returns:
|
145
|
+
List of EmbeddedResource objects ready to use in a PromptMessageMultipart
|
146
|
+
"""
|
147
|
+
return await self._agent.get_embedded_resources(server_name, resource_name)
|
148
|
+
|
149
|
+
async def with_resource(
|
150
|
+
self,
|
151
|
+
prompt_content: Union[str, PromptMessageMultipart],
|
152
|
+
server_name: str,
|
153
|
+
resource_name: str,
|
154
|
+
) -> str:
|
155
|
+
"""
|
156
|
+
Create a prompt with the given content and resource, then send it to the agent.
|
157
|
+
|
158
|
+
Args:
|
159
|
+
prompt_content: Either a string message or an existing PromptMessageMultipart
|
160
|
+
server_name: Name of the MCP server to retrieve the resource from
|
161
|
+
resource_name: Name or URI of the resource to retrieve
|
162
|
+
|
163
|
+
Returns:
|
164
|
+
The agent's response as a string
|
165
|
+
"""
|
166
|
+
return await self._agent.with_resource(
|
167
|
+
prompt_content, server_name, resource_name
|
168
|
+
)
|
169
|
+
|
132
170
|
|
133
171
|
class WorkflowProxy(BaseAgentProxy):
|
134
172
|
"""Proxy for workflow types that implement generate_str() directly"""
|
@@ -177,10 +177,7 @@ class BatchingListener(FilteredListener):
|
|
177
177
|
|
178
178
|
if self._flush_task and not self._flush_task.done():
|
179
179
|
self._flush_task.cancel()
|
180
|
-
|
181
|
-
await self._flush_task
|
182
|
-
except asyncio.CancelledError:
|
183
|
-
pass
|
180
|
+
await self._flush_task
|
184
181
|
self._flush_task = None
|
185
182
|
await self.flush()
|
186
183
|
|
@@ -193,8 +190,8 @@ class BatchingListener(FilteredListener):
|
|
193
190
|
)
|
194
191
|
except asyncio.TimeoutError:
|
195
192
|
await self.flush()
|
196
|
-
except asyncio.CancelledError:
|
197
|
-
|
193
|
+
# except asyncio.CancelledError:
|
194
|
+
# break
|
198
195
|
finally:
|
199
196
|
await self.flush() # Final flush
|
200
197
|
|
@@ -0,0 +1,118 @@
|
|
1
|
+
"""
|
2
|
+
A derived client session for the MCP Agent framework.
|
3
|
+
It adds logging and supports sampling requests.
|
4
|
+
"""
|
5
|
+
|
6
|
+
from typing import Optional
|
7
|
+
|
8
|
+
from mcp import ClientSession
|
9
|
+
from mcp.shared.session import (
|
10
|
+
ReceiveResultT,
|
11
|
+
ReceiveNotificationT,
|
12
|
+
RequestId,
|
13
|
+
SendNotificationT,
|
14
|
+
SendRequestT,
|
15
|
+
SendResultT,
|
16
|
+
)
|
17
|
+
from mcp.types import (
|
18
|
+
ErrorData,
|
19
|
+
ListRootsResult,
|
20
|
+
Root,
|
21
|
+
)
|
22
|
+
from pydantic import AnyUrl
|
23
|
+
|
24
|
+
from mcp_agent.config import MCPServerSettings
|
25
|
+
from mcp_agent.context_dependent import ContextDependent
|
26
|
+
from mcp_agent.logging.logger import get_logger
|
27
|
+
|
28
|
+
logger = get_logger(__name__)
|
29
|
+
|
30
|
+
|
31
|
+
async def list_roots(ctx: ClientSession) -> ListRootsResult:
|
32
|
+
"""List roots callback that will be called by the MCP library."""
|
33
|
+
|
34
|
+
roots = []
|
35
|
+
if (
|
36
|
+
hasattr(ctx, "session")
|
37
|
+
and hasattr(ctx.session, "server_config")
|
38
|
+
and ctx.session.server_config
|
39
|
+
and hasattr(ctx.session.server_config, "roots")
|
40
|
+
and ctx.session.server_config.roots
|
41
|
+
):
|
42
|
+
roots = [
|
43
|
+
Root(uri=AnyUrl(root.uri), name=root.name)
|
44
|
+
for root in ctx.session.server_config.roots
|
45
|
+
]
|
46
|
+
return ListRootsResult(roots=roots or [])
|
47
|
+
|
48
|
+
|
49
|
+
class MCPAgentClientSession(ClientSession, ContextDependent):
|
50
|
+
"""
|
51
|
+
MCP Agent framework acts as a client to the servers providing tools/resources/prompts for the agent workloads.
|
52
|
+
This is a simple client session for those server connections, and supports
|
53
|
+
- handling sampling requests
|
54
|
+
- notifications
|
55
|
+
- MCP root configuration
|
56
|
+
|
57
|
+
Developers can extend this class to add more custom functionality as needed
|
58
|
+
"""
|
59
|
+
|
60
|
+
def __init__(self, *args, **kwargs):
|
61
|
+
super().__init__(*args, **kwargs, list_roots_callback=list_roots)
|
62
|
+
self.server_config: Optional[MCPServerSettings] = None
|
63
|
+
|
64
|
+
async def send_request(
|
65
|
+
self,
|
66
|
+
request: SendRequestT,
|
67
|
+
result_type: type[ReceiveResultT],
|
68
|
+
) -> ReceiveResultT:
|
69
|
+
logger.debug("send_request: request=", data=request.model_dump())
|
70
|
+
try:
|
71
|
+
result = await super().send_request(request, result_type)
|
72
|
+
logger.debug("send_request: response=", data=result.model_dump())
|
73
|
+
return result
|
74
|
+
except Exception as e:
|
75
|
+
logger.error(f"send_request failed: {str(e)}")
|
76
|
+
raise
|
77
|
+
|
78
|
+
async def send_notification(self, notification: SendNotificationT) -> None:
|
79
|
+
logger.debug("send_notification:", data=notification.model_dump())
|
80
|
+
try:
|
81
|
+
return await super().send_notification(notification)
|
82
|
+
except Exception as e:
|
83
|
+
logger.error("send_notification failed", data=e)
|
84
|
+
raise
|
85
|
+
|
86
|
+
async def _send_response(
|
87
|
+
self, request_id: RequestId, response: SendResultT | ErrorData
|
88
|
+
) -> None:
|
89
|
+
logger.debug(
|
90
|
+
f"send_response: request_id={request_id}, response=",
|
91
|
+
data=response.model_dump(),
|
92
|
+
)
|
93
|
+
return await super()._send_response(request_id, response)
|
94
|
+
|
95
|
+
async def _received_notification(self, notification: ReceiveNotificationT) -> None:
|
96
|
+
"""
|
97
|
+
Can be overridden by subclasses to handle a notification without needing
|
98
|
+
to listen on the message stream.
|
99
|
+
"""
|
100
|
+
logger.info(
|
101
|
+
"_received_notification: notification=",
|
102
|
+
data=notification.model_dump(),
|
103
|
+
)
|
104
|
+
return await super()._received_notification(notification)
|
105
|
+
|
106
|
+
async def send_progress_notification(
|
107
|
+
self, progress_token: str | int, progress: float, total: float | None = None
|
108
|
+
) -> None:
|
109
|
+
"""
|
110
|
+
Sends a progress notification for a request that is currently being
|
111
|
+
processed.
|
112
|
+
"""
|
113
|
+
logger.debug(
|
114
|
+
"send_progress_notification: progress_token={progress_token}, progress={progress}, total={total}"
|
115
|
+
)
|
116
|
+
return await super().send_progress_notification(
|
117
|
+
progress_token=progress_token, progress=progress, total=total
|
118
|
+
)
|
@@ -8,8 +8,8 @@ from typing import (
|
|
8
8
|
Callable,
|
9
9
|
TypeVar,
|
10
10
|
)
|
11
|
-
from mcp import GetPromptResult
|
12
|
-
from pydantic import BaseModel, ConfigDict
|
11
|
+
from mcp import GetPromptResult, ReadResourceResult
|
12
|
+
from pydantic import AnyUrl, BaseModel, ConfigDict
|
13
13
|
from mcp.client.session import ClientSession
|
14
14
|
from mcp.server.lowlevel.server import Server
|
15
15
|
from mcp.server.stdio import stdio_server
|
@@ -210,6 +210,7 @@ class MCPAggregator(ContextDependent):
|
|
210
210
|
"agent_name": self.agent_name,
|
211
211
|
},
|
212
212
|
)
|
213
|
+
|
213
214
|
await self._persistent_connection_manager.get_server(
|
214
215
|
server_name, client_session_factory=MCPAgentClientSession
|
215
216
|
)
|
@@ -821,6 +822,53 @@ class MCPAggregator(ContextDependent):
|
|
821
822
|
logger.debug(f"Available prompts across servers: {results}")
|
822
823
|
return results
|
823
824
|
|
825
|
+
async def get_resource(
|
826
|
+
self, server_name: str, resource_uri: str
|
827
|
+
) -> ReadResourceResult:
|
828
|
+
"""
|
829
|
+
Get a resource directly from an MCP server by URI.
|
830
|
+
|
831
|
+
Args:
|
832
|
+
server_name: Name of the MCP server to retrieve the resource from
|
833
|
+
resource_uri: URI of the resource to retrieve
|
834
|
+
|
835
|
+
Returns:
|
836
|
+
ReadResourceResult object containing the resource content
|
837
|
+
|
838
|
+
Raises:
|
839
|
+
ValueError: If the server doesn't exist or the resource couldn't be found
|
840
|
+
"""
|
841
|
+
if not self.initialized:
|
842
|
+
await self.load_servers()
|
843
|
+
|
844
|
+
if server_name not in self.server_names:
|
845
|
+
raise ValueError(f"Server '{server_name}' not found")
|
846
|
+
|
847
|
+
logger.info(
|
848
|
+
"Requesting resource",
|
849
|
+
data={
|
850
|
+
"progress_action": ProgressAction.CALLING_TOOL,
|
851
|
+
"resource_uri": resource_uri,
|
852
|
+
"server_name": server_name,
|
853
|
+
"agent_name": self.agent_name,
|
854
|
+
},
|
855
|
+
)
|
856
|
+
|
857
|
+
try:
|
858
|
+
uri = AnyUrl(resource_uri)
|
859
|
+
except Exception as e:
|
860
|
+
raise ValueError(f"Invalid resource URI: {resource_uri}. Error: {e}")
|
861
|
+
|
862
|
+
# Use the _execute_on_server method to call read_resource on the server
|
863
|
+
return await self._execute_on_server(
|
864
|
+
server_name=server_name,
|
865
|
+
operation_type="resource",
|
866
|
+
operation_name=resource_uri,
|
867
|
+
method_name="read_resource",
|
868
|
+
method_args={"uri": uri},
|
869
|
+
error_factory=lambda msg: ValueError(f"Failed to retrieve resource: {msg}"),
|
870
|
+
)
|
871
|
+
|
824
872
|
|
825
873
|
class MCPCompoundServer(Server):
|
826
874
|
"""
|
@@ -163,7 +163,6 @@ async def _server_lifecycle_task(server_conn: ServerConnection) -> None:
|
|
163
163
|
async with transport_context as (read_stream, write_stream):
|
164
164
|
# try:
|
165
165
|
server_conn.create_session(read_stream, write_stream)
|
166
|
-
# except FileNotFoundError as e:
|
167
166
|
|
168
167
|
async with server_conn.session:
|
169
168
|
await server_conn.initialize_session()
|
@@ -12,6 +12,8 @@ import logging
|
|
12
12
|
import sys
|
13
13
|
from pathlib import Path
|
14
14
|
from typing import List, Dict, Optional, Callable, Awaitable, Literal, Any
|
15
|
+
from mcp.server.fastmcp.resources import FileResource
|
16
|
+
from pydantic import AnyUrl
|
15
17
|
|
16
18
|
from mcp_agent.mcp import mime_utils, resource_utils
|
17
19
|
|
@@ -185,19 +187,19 @@ def create_prompt_handler(
|
|
185
187
|
|
186
188
|
|
187
189
|
# Type for resource handler
|
188
|
-
ResourceHandler = Callable[[], Awaitable[str]]
|
190
|
+
ResourceHandler = Callable[[], Awaitable[str | bytes]]
|
189
191
|
|
190
192
|
|
191
193
|
def create_resource_handler(resource_path: Path, mime_type: str) -> ResourceHandler:
|
192
194
|
"""Create a resource handler function for the given resource"""
|
193
195
|
|
194
|
-
async def get_resource() -> str:
|
196
|
+
async def get_resource() -> str | bytes:
|
195
197
|
is_binary = mime_utils.is_binary_content(mime_type)
|
196
198
|
|
197
199
|
if is_binary:
|
198
200
|
# For binary files, read in binary mode and base64 encode
|
199
201
|
with open(resource_path, "rb") as f:
|
200
|
-
return
|
202
|
+
return f.read()
|
201
203
|
else:
|
202
204
|
# For text files, read as utf-8 text
|
203
205
|
with open(resource_path, "r", encoding="utf-8") as f:
|
@@ -284,15 +286,14 @@ def register_prompt(file_path: Path):
|
|
284
286
|
exposed_resources[resource_id] = resource_file
|
285
287
|
mime_type = mime_utils.guess_mime_type(str(resource_file))
|
286
288
|
|
287
|
-
|
288
|
-
|
289
|
-
|
289
|
+
mcp.add_resource(
|
290
|
+
FileResource(
|
291
|
+
uri=AnyUrl(resource_id),
|
292
|
+
path=resource_file,
|
293
|
+
mime_type=mime_type,
|
294
|
+
is_binary=mime_utils.is_binary_content(mime_type),
|
295
|
+
)
|
290
296
|
)
|
291
|
-
mcp.resource(
|
292
|
-
resource_id,
|
293
|
-
description=f"Resource from {file_path.name}",
|
294
|
-
mime_type=mime_type,
|
295
|
-
)(resource_handler)
|
296
297
|
|
297
298
|
logger.info(
|
298
299
|
f"Registered resource: {resource_id} ({resource_file})"
|