fast-agent-mcp 0.1.11__tar.gz → 0.1.12__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.
Files changed (168) hide show
  1. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/PKG-INFO +1 -1
  2. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/pyproject.toml +1 -1
  3. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/agents/agent.py +1 -24
  4. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/app.py +0 -5
  5. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/context.py +0 -2
  6. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/agent_app.py +1 -1
  7. fast_agent_mcp-0.1.12/src/mcp_agent/core/agent_types.py +43 -0
  8. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/decorators.py +1 -2
  9. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/error_handling.py +1 -1
  10. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/factory.py +2 -3
  11. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/mcp_content.py +2 -3
  12. fast_agent_mcp-0.1.12/src/mcp_agent/core/request_params.py +43 -0
  13. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/types.py +4 -2
  14. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/validation.py +14 -15
  15. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/logging/transport.py +2 -2
  16. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/interfaces.py +37 -3
  17. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/mcp_agent_client_session.py +1 -1
  18. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/mcp_aggregator.py +5 -6
  19. fast_agent_mcp-0.1.12/src/mcp_agent/mcp/sampling.py +140 -0
  20. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp_server/__init__.py +1 -1
  21. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/prompting/__init__.py +1 -1
  22. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/ui/console_display.py +2 -2
  23. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/evaluator_optimizer/evaluator_optimizer.py +2 -2
  24. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/augmented_llm.py +42 -102
  25. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/augmented_llm_anthropic.py +4 -3
  26. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/augmented_llm_openai.py +4 -3
  27. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/augmented_llm_passthrough.py +33 -4
  28. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/model_factory.py +1 -1
  29. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/prompt_utils.py +42 -28
  30. fast_agent_mcp-0.1.12/src/mcp_agent/workflows/llm/providers/multipart_converter_anthropic.py +452 -0
  31. fast_agent_mcp-0.1.12/src/mcp_agent/workflows/llm/providers/multipart_converter_openai.py +471 -0
  32. fast_agent_mcp-0.1.12/src/mcp_agent/workflows/llm/providers/sampling_converter_anthropic.py +59 -0
  33. fast_agent_mcp-0.1.12/src/mcp_agent/workflows/llm/providers/sampling_converter_openai.py +31 -0
  34. fast_agent_mcp-0.1.12/src/mcp_agent/workflows/llm/sampling_converter.py +124 -0
  35. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/sampling_format_converter.py +0 -17
  36. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/router/router_base.py +10 -10
  37. fast_agent_mcp-0.1.11/src/mcp_agent/core/agent_types.py +0 -16
  38. fast_agent_mcp-0.1.11/src/mcp_agent/mcp/sampling.py +0 -133
  39. fast_agent_mcp-0.1.11/src/mcp_agent/workflows/llm/llm_selector.py +0 -345
  40. fast_agent_mcp-0.1.11/src/mcp_agent/workflows/llm/providers/multipart_converter_anthropic.py +0 -348
  41. fast_agent_mcp-0.1.11/src/mcp_agent/workflows/llm/providers/multipart_converter_openai.py +0 -426
  42. fast_agent_mcp-0.1.11/src/mcp_agent/workflows/llm/providers/sampling_converter_anthropic.py +0 -258
  43. fast_agent_mcp-0.1.11/src/mcp_agent/workflows/llm/providers/sampling_converter_openai.py +0 -229
  44. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/.gitignore +0 -0
  45. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/LICENSE +0 -0
  46. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/README.md +0 -0
  47. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/__init__.py +0 -0
  48. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/agents/__init__.py +0 -0
  49. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/cli/__init__.py +0 -0
  50. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/cli/__main__.py +0 -0
  51. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/cli/commands/bootstrap.py +0 -0
  52. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/cli/commands/config.py +0 -0
  53. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/cli/commands/setup.py +0 -0
  54. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/cli/main.py +0 -0
  55. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/cli/terminal.py +0 -0
  56. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/config.py +0 -0
  57. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/console.py +0 -0
  58. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/context_dependent.py +0 -0
  59. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/__init__.py +0 -0
  60. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/agent_utils.py +0 -0
  61. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/enhanced_prompt.py +0 -0
  62. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/exceptions.py +0 -0
  63. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/fastagent.py +0 -0
  64. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/prompt.py +0 -0
  65. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/core/proxies.py +0 -0
  66. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/eval/__init__.py +0 -0
  67. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/event_progress.py +0 -0
  68. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/executor/__init__.py +0 -0
  69. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/executor/decorator_registry.py +0 -0
  70. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/executor/executor.py +0 -0
  71. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/executor/task_registry.py +0 -0
  72. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/executor/temporal.py +0 -0
  73. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/executor/workflow.py +0 -0
  74. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/executor/workflow_signal.py +0 -0
  75. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/human_input/__init__.py +0 -0
  76. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/human_input/handler.py +0 -0
  77. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/human_input/types.py +0 -0
  78. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/logging/__init__.py +0 -0
  79. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/logging/events.py +0 -0
  80. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/logging/json_serializer.py +0 -0
  81. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/logging/listeners.py +0 -0
  82. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/logging/logger.py +0 -0
  83. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/logging/rich_progress.py +0 -0
  84. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/logging/tracing.py +0 -0
  85. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/__init__.py +0 -0
  86. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/gen_client.py +0 -0
  87. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/mcp_activity.py +0 -0
  88. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/mcp_agent_server.py +0 -0
  89. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/mcp_connection_manager.py +0 -0
  90. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/mime_utils.py +0 -0
  91. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/prompt_message_multipart.py +0 -0
  92. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/prompt_serialization.py +0 -0
  93. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/prompts/__init__.py +0 -0
  94. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/prompts/__main__.py +0 -0
  95. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/prompts/prompt_server.py +0 -0
  96. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/prompts/prompt_template.py +0 -0
  97. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/resource_utils.py +0 -0
  98. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp/stdio.py +0 -0
  99. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp_server/agent_server.py +0 -0
  100. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/mcp_server_registry.py +0 -0
  101. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/progress_display.py +0 -0
  102. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/data-analysis/analysis-campaign.py +0 -0
  103. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/data-analysis/analysis.py +0 -0
  104. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/data-analysis/fastagent.config.yaml +0 -0
  105. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv +0 -0
  106. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/internal/agent.py +0 -0
  107. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/internal/fastagent.config.yaml +0 -0
  108. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/internal/job.py +0 -0
  109. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/internal/prompt_category.py +0 -0
  110. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/internal/prompt_sizing.py +0 -0
  111. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/internal/sizer.py +0 -0
  112. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/internal/social.py +0 -0
  113. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/mcp_researcher/researcher-eval.py +0 -0
  114. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/prompting/agent.py +0 -0
  115. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/prompting/fastagent.config.yaml +0 -0
  116. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/prompting/image_server.py +0 -0
  117. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/researcher/fastagent.config.yaml +0 -0
  118. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/researcher/researcher-eval.py +0 -0
  119. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/researcher/researcher-imp.py +0 -0
  120. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/researcher/researcher.py +0 -0
  121. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/agent_build.py +0 -0
  122. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/chaining.py +0 -0
  123. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/evaluator.py +0 -0
  124. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/fastagent.config.yaml +0 -0
  125. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/human_input.py +0 -0
  126. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/orchestrator.py +0 -0
  127. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/parallel.py +0 -0
  128. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/router.py +0 -0
  129. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/resources/examples/workflows/sse.py +0 -0
  130. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/telemetry/__init__.py +0 -0
  131. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/telemetry/usage_tracking.py +0 -0
  132. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/__init__.py +0 -0
  133. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/embedding/__init__.py +0 -0
  134. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/embedding/embedding_base.py +0 -0
  135. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/embedding/embedding_cohere.py +0 -0
  136. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/embedding/embedding_openai.py +0 -0
  137. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/evaluator_optimizer/__init__.py +0 -0
  138. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/intent_classifier/__init__.py +0 -0
  139. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/intent_classifier/intent_classifier_base.py +0 -0
  140. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/intent_classifier/intent_classifier_embedding.py +0 -0
  141. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/intent_classifier/intent_classifier_embedding_cohere.py +0 -0
  142. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/intent_classifier/intent_classifier_embedding_openai.py +0 -0
  143. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/intent_classifier/intent_classifier_llm.py +0 -0
  144. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/intent_classifier/intent_classifier_llm_anthropic.py +0 -0
  145. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/intent_classifier/intent_classifier_llm_openai.py +0 -0
  146. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/__init__.py +0 -0
  147. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/anthropic_utils.py +0 -0
  148. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/augmented_llm_playback.py +0 -0
  149. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/openai_utils.py +0 -0
  150. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/providers/__init__.py +0 -0
  151. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/llm/providers/openai_multipart.py +0 -0
  152. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/orchestrator/__init__.py +0 -0
  153. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/orchestrator/orchestrator.py +0 -0
  154. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/orchestrator/orchestrator_models.py +0 -0
  155. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/orchestrator/orchestrator_prompts.py +0 -0
  156. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/parallel/__init__.py +0 -0
  157. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/parallel/fan_in.py +0 -0
  158. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/parallel/fan_out.py +0 -0
  159. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/parallel/parallel_llm.py +0 -0
  160. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/router/__init__.py +0 -0
  161. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/router/router_embedding.py +0 -0
  162. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/router/router_embedding_cohere.py +0 -0
  163. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/router/router_embedding_openai.py +0 -0
  164. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/router/router_llm.py +0 -0
  165. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/swarm/__init__.py +0 -0
  166. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/swarm/swarm.py +0 -0
  167. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/src/mcp_agent/workflows/swarm/swarm_anthropic.py +0 -0
  168. {fast_agent_mcp-0.1.11 → fast_agent_mcp-0.1.12}/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.11
3
+ Version: 0.1.12
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
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fast-agent-mcp"
3
- version = "0.1.11"
3
+ version = "0.1.12"
4
4
  description = "Define, Prompt and Test MCP enabled Agents and Workflows"
5
5
  readme = "README.md"
6
6
  license = { file = "LICENSE" }
@@ -1,6 +1,5 @@
1
1
  import asyncio
2
2
  import uuid
3
- from dataclasses import dataclass
4
3
  from typing import Callable, Dict, List, Optional, TypeVar, Union, TYPE_CHECKING
5
4
 
6
5
  from mcp.server.fastmcp.tools import Tool as FastTool
@@ -16,7 +15,7 @@ from mcp_agent.mcp.prompt_message_multipart import PromptMessageMultipart
16
15
 
17
16
  from mcp_agent.core.exceptions import PromptExitError
18
17
  from mcp_agent.mcp.mcp_aggregator import MCPAggregator
19
- from mcp_agent.workflows.llm.augmented_llm import RequestParams
18
+ from mcp_agent.core.agent_types import AgentConfig
20
19
  from mcp_agent.human_input.types import (
21
20
  HumanInputCallback,
22
21
  HumanInputRequest,
@@ -38,28 +37,6 @@ LLM = TypeVar("LLM", bound=AugmentedLLM)
38
37
  HUMAN_INPUT_TOOL_NAME = "__human_input__"
39
38
 
40
39
 
41
- @dataclass
42
- class AgentConfig:
43
- """Configuration for an Agent instance"""
44
-
45
- name: str
46
- instruction: Union[str, Callable[[Dict], str]]
47
- servers: List[str]
48
- model: Optional[str] = None
49
- use_history: bool = True
50
- default_request_params: Optional[RequestParams] = None
51
- human_input: bool = False
52
-
53
- def __post_init__(self):
54
- """Ensure default_request_params exists with proper history setting"""
55
-
56
- if self.default_request_params is None:
57
- self.default_request_params = RequestParams(use_history=self.use_history)
58
- else:
59
- # Override the request params history setting if explicitly configured
60
- self.default_request_params.use_history = self.use_history
61
-
62
-
63
40
  class Agent(MCPAggregator):
64
41
  """
65
42
  An Agent is an entity that has access to a set of MCP servers and can interact with them.
@@ -11,7 +11,6 @@ from mcp_agent.logging.logger import get_logger
11
11
  from mcp_agent.executor.workflow_signal import SignalWaitCallback
12
12
  from mcp_agent.human_input.types import HumanInputCallback
13
13
  from mcp_agent.human_input.handler import console_input_callback
14
- from mcp_agent.workflows.llm.llm_selector import ModelSelector
15
14
 
16
15
  R = TypeVar("R")
17
16
 
@@ -44,7 +43,6 @@ class MCPApp:
44
43
  human_input_callback: Optional[HumanInputCallback] = console_input_callback,
45
44
  signal_notification: Optional[SignalWaitCallback] = None,
46
45
  upstream_session: Optional["ServerSession"] = None,
47
- model_selector: ModelSelector = None,
48
46
  ):
49
47
  """
50
48
  Initialize the application with a name and optional settings.
@@ -55,7 +53,6 @@ class MCPApp:
55
53
  human_input_callback: Callback for handling human input
56
54
  signal_notification: Callback for getting notified on workflow signals/events.
57
55
  upstream_session: Optional upstream session if the MCPApp is running as a server to an MCP client.
58
- initialize_model_selector: Initializes the built-in ModelSelector to help with model selection. Defaults to False.
59
56
  """
60
57
  self.name = name
61
58
 
@@ -64,7 +61,6 @@ class MCPApp:
64
61
  self._human_input_callback = human_input_callback
65
62
  self._signal_notification = signal_notification
66
63
  self._upstream_session = upstream_session
67
- self._model_selector = model_selector
68
64
 
69
65
  self._workflows: Dict[str, Type] = {} # id to workflow class
70
66
  self._logger = None
@@ -128,7 +124,6 @@ class MCPApp:
128
124
  self._context.human_input_handler = self._human_input_callback
129
125
  self._context.signal_notification = self._signal_notification
130
126
  self._context.upstream_session = self._upstream_session
131
- self._context.model_selector = self._model_selector
132
127
 
133
128
  self._initialized = True
134
129
  self.logger.info(
@@ -32,7 +32,6 @@ from mcp_agent.logging.events import EventFilter
32
32
  from mcp_agent.logging.logger import LoggingConfig
33
33
  from mcp_agent.logging.transport import create_transport
34
34
  from mcp_agent.mcp_server_registry import ServerRegistry
35
- from mcp_agent.workflows.llm.llm_selector import ModelSelector
36
35
  from mcp_agent.logging.logger import get_logger
37
36
 
38
37
 
@@ -58,7 +57,6 @@ class Context(BaseModel):
58
57
  human_input_handler: Optional[HumanInputCallback] = None
59
58
  signal_notification: Optional[SignalWaitCallback] = None
60
59
  upstream_session: Optional[ServerSession] = None # TODO: saqadri - figure this out
61
- model_selector: Optional[ModelSelector] = None
62
60
 
63
61
  # Registries
64
62
  server_registry: Optional[ServerRegistry] = None
@@ -112,7 +112,7 @@ class AgentApp:
112
112
 
113
113
  proxy = self._agents[target]
114
114
  return await proxy.apply_prompt(prompt_name, arguments)
115
-
115
+
116
116
  async def with_resource(
117
117
  self,
118
118
  prompt_content: Union[str, PromptMessageMultipart],
@@ -0,0 +1,43 @@
1
+ """
2
+ Type definitions for agents and agent configurations.
3
+ """
4
+
5
+ from dataclasses import dataclass
6
+ from enum import Enum
7
+ from typing import Callable, Dict, List, Optional, Union
8
+
9
+ # Forward imports to avoid circular dependencies
10
+ from mcp_agent.core.request_params import RequestParams
11
+
12
+
13
+ class AgentType(Enum):
14
+ """Enumeration of supported agent types."""
15
+
16
+ BASIC = "agent"
17
+ ORCHESTRATOR = "orchestrator"
18
+ PARALLEL = "parallel"
19
+ EVALUATOR_OPTIMIZER = "evaluator_optimizer"
20
+ ROUTER = "router"
21
+ CHAIN = "chain"
22
+
23
+
24
+ @dataclass
25
+ class AgentConfig:
26
+ """Configuration for an Agent instance"""
27
+
28
+ name: str
29
+ instruction: Union[str, Callable[[Dict], str]]
30
+ servers: List[str]
31
+ model: Optional[str] = None
32
+ use_history: bool = True
33
+ default_request_params: Optional[RequestParams] = None
34
+ human_input: bool = False
35
+
36
+ def __post_init__(self):
37
+ """Ensure default_request_params exists with proper history setting"""
38
+
39
+ if self.default_request_params is None:
40
+ self.default_request_params = RequestParams(use_history=self.use_history)
41
+ else:
42
+ # Override the request params history setting if explicitly configured
43
+ self.default_request_params.use_history = self.use_history
@@ -4,9 +4,8 @@ Contains decorator definitions extracted from fastagent.py.
4
4
  """
5
5
 
6
6
  from typing import Callable, Dict, List, Optional, TypeVar, Literal
7
- from mcp_agent.agents.agent import AgentConfig
7
+ from mcp_agent.core.agent_types import AgentConfig, AgentType
8
8
  from mcp_agent.workflows.llm.augmented_llm import RequestParams
9
- from mcp_agent.core.agent_types import AgentType
10
9
 
11
10
  T = TypeVar("T") # For the wrapper classes
12
11
 
@@ -20,4 +20,4 @@ def handle_error(e: Exception, error_type: str, suggestion: str = None) -> None:
20
20
  print("\nDetails:")
21
21
  print(e.details)
22
22
  if suggestion:
23
- print(f"\n{suggestion}")
23
+ print(f"\n{suggestion}")
@@ -5,7 +5,8 @@ Factory functions for creating agent and workflow instances.
5
5
  from typing import Dict, Any, Optional, TypeVar, Callable
6
6
 
7
7
  from mcp_agent.app import MCPApp
8
- from mcp_agent.agents.agent import Agent, AgentConfig
8
+ from mcp_agent.agents.agent import Agent
9
+ from mcp_agent.core.agent_types import AgentConfig, AgentType
9
10
  from mcp_agent.event_progress import ProgressAction
10
11
  from mcp_agent.workflows.evaluator_optimizer.evaluator_optimizer import (
11
12
  EvaluatorOptimizerLLM,
@@ -16,8 +17,6 @@ from mcp_agent.workflows.llm.model_factory import ModelFactory
16
17
  from mcp_agent.workflows.orchestrator.orchestrator import Orchestrator
17
18
  from mcp_agent.workflows.parallel.parallel_llm import ParallelLLM
18
19
  from mcp_agent.workflows.router.router_llm import LLMRouter
19
-
20
- from mcp_agent.core.agent_types import AgentType
21
20
  from mcp_agent.core.exceptions import AgentConfigError
22
21
  from mcp_agent.core.proxies import (
23
22
  BaseAgentProxy,
@@ -146,7 +146,6 @@ def MCPFile(
146
146
  }
147
147
 
148
148
 
149
-
150
149
  def MCPPrompt(
151
150
  *content_items, role: Literal["user", "assistant"] = "user"
152
151
  ) -> List[dict]:
@@ -154,7 +153,7 @@ def MCPPrompt(
154
153
  Create one or more prompt messages with various content types.
155
154
 
156
155
  This function intelligently creates different content types:
157
- - Strings become TextContent
156
+ - Strings become TextContent
158
157
  - File paths with image mime types become ImageContent
159
158
  - File paths with text mime types or other mime types become EmbeddedResource
160
159
  - Dicts with role and content are passed through unchanged
@@ -180,7 +179,7 @@ def MCPPrompt(
180
179
  # File path - determine the content type based on mime type
181
180
  path_str = str(item)
182
181
  mime_type = guess_mime_type(path_str)
183
-
182
+
184
183
  if is_image_mime_type(mime_type):
185
184
  # Image files (except SVG which is handled as text)
186
185
  result.append(MCPImage(path=item, role=role))
@@ -0,0 +1,43 @@
1
+ """
2
+ Request parameters definitions for LLM interactions.
3
+ """
4
+
5
+ from pydantic import Field
6
+ from mcp.types import CreateMessageRequestParams
7
+
8
+
9
+ class RequestParams(CreateMessageRequestParams):
10
+ """
11
+ Parameters to configure the AugmentedLLM 'generate' requests.
12
+ """
13
+
14
+ messages: None = Field(exclude=True, default=None)
15
+ """
16
+ Ignored. 'messages' are removed from CreateMessageRequestParams
17
+ to avoid confusion with the 'message' parameter on 'generate' method.
18
+ """
19
+
20
+ maxTokens: int = 2048
21
+ """The maximum number of tokens to sample, as requested by the server."""
22
+
23
+ model: str | None = None
24
+ """
25
+ The model to use for the LLM generation.
26
+ If specified, this overrides the 'modelPreferences' selection criteria.
27
+ """
28
+
29
+ use_history: bool = True
30
+ """
31
+ Include the message history in the generate request.
32
+ """
33
+
34
+ max_iterations: int = 10
35
+ """
36
+ The maximum number of iterations to run the LLM for.
37
+ """
38
+
39
+ parallel_tool_calls: bool = True
40
+ """
41
+ Whether to allow multiple tool calls per iteration.
42
+ Also known as multi-step tool use.
43
+ """
@@ -7,7 +7,9 @@ from typing import Dict, Union, TypeAlias, TYPE_CHECKING
7
7
  from mcp_agent.agents.agent import Agent
8
8
  from mcp_agent.workflows.orchestrator.orchestrator import Orchestrator
9
9
  from mcp_agent.workflows.parallel.parallel_llm import ParallelLLM
10
- from mcp_agent.workflows.evaluator_optimizer.evaluator_optimizer import EvaluatorOptimizerLLM
10
+ from mcp_agent.workflows.evaluator_optimizer.evaluator_optimizer import (
11
+ EvaluatorOptimizerLLM,
12
+ )
11
13
  from mcp_agent.workflows.router.router_llm import LLMRouter
12
14
 
13
15
  # Avoid circular imports
@@ -19,4 +21,4 @@ WorkflowType: TypeAlias = Union[
19
21
  Orchestrator, ParallelLLM, EvaluatorOptimizerLLM, LLMRouter
20
22
  ]
21
23
  AgentOrWorkflow: TypeAlias = Union[Agent, WorkflowType]
22
- ProxyDict: TypeAlias = Dict[str, "BaseAgentProxy"] # Forward reference as string
24
+ ProxyDict: TypeAlias = Dict[str, "BaseAgentProxy"] # Forward reference as string
@@ -5,14 +5,18 @@ Validation utilities for FastAgent configuration and dependencies.
5
5
  from typing import Dict, List, Any
6
6
  from mcp_agent.core.agent_types import AgentType
7
7
  from mcp_agent.workflows.llm.augmented_llm import AugmentedLLM
8
- from mcp_agent.core.exceptions import ServerConfigError, AgentConfigError, CircularDependencyError
8
+ from mcp_agent.core.exceptions import (
9
+ ServerConfigError,
10
+ AgentConfigError,
11
+ CircularDependencyError,
12
+ )
9
13
 
10
14
 
11
15
  def validate_server_references(context, agents: Dict[str, Dict[str, Any]]) -> None:
12
16
  """
13
17
  Validate that all server references in agent configurations exist in config.
14
18
  Raises ServerConfigError if any referenced servers are not defined.
15
-
19
+
16
20
  Args:
17
21
  context: Application context
18
22
  agents: Dictionary of agent configurations
@@ -39,7 +43,7 @@ def validate_workflow_references(agents: Dict[str, Dict[str, Any]]) -> None:
39
43
  Validate that all workflow references point to valid agents/workflows.
40
44
  Also validates that referenced agents have required configuration.
41
45
  Raises AgentConfigError if any validation fails.
42
-
46
+
43
47
  Args:
44
48
  agents: Dictionary of agent configurations
45
49
  """
@@ -133,11 +137,11 @@ def validate_workflow_references(agents: Dict[str, Dict[str, Any]]) -> None:
133
137
 
134
138
 
135
139
  def get_dependencies(
136
- name: str,
140
+ name: str,
137
141
  agents: Dict[str, Dict[str, Any]],
138
- visited: set,
139
- path: set,
140
- agent_type: AgentType = None
142
+ visited: set,
143
+ path: set,
144
+ agent_type: AgentType = None,
141
145
  ) -> List[str]:
142
146
  """
143
147
  Get dependencies for an agent in topological order.
@@ -184,9 +188,7 @@ def get_dependencies(
184
188
  # Get dependencies from sequence agents
185
189
  sequence = config.get("sequence", config.get("agents", []))
186
190
  for agent_name in sequence:
187
- deps.extend(
188
- get_dependencies(agent_name, agents, visited, path, agent_type)
189
- )
191
+ deps.extend(get_dependencies(agent_name, agents, visited, path, agent_type))
190
192
 
191
193
  # Add this agent after its dependencies
192
194
  deps.append(name)
@@ -197,10 +199,7 @@ def get_dependencies(
197
199
 
198
200
 
199
201
  def get_parallel_dependencies(
200
- name: str,
201
- agents: Dict[str, Dict[str, Any]],
202
- visited: set,
203
- path: set
202
+ name: str, agents: Dict[str, Dict[str, Any]], visited: set, path: set
204
203
  ) -> List[str]:
205
204
  """
206
205
  Get dependencies for a parallel agent in topological order.
@@ -218,4 +217,4 @@ def get_parallel_dependencies(
218
217
  Raises:
219
218
  CircularDependencyError: If circular dependency detected
220
219
  """
221
- return get_dependencies(name, agents, visited, path, AgentType.PARALLEL)
220
+ return get_dependencies(name, agents, visited, path, AgentType.PARALLEL)
@@ -290,7 +290,7 @@ class AsyncEventBus:
290
290
  # Update transport if provided
291
291
  cls._instance.transport = transport
292
292
  return cls._instance
293
-
293
+
294
294
  @classmethod
295
295
  def reset(cls) -> None:
296
296
  """
@@ -302,7 +302,7 @@ class AsyncEventBus:
302
302
  # Signal shutdown
303
303
  cls._instance._running = False
304
304
  cls._instance._stop_event.set()
305
-
305
+
306
306
  # Clear the singleton instance
307
307
  cls._instance = None
308
308
 
@@ -4,12 +4,24 @@ This module defines protocols (interfaces) that can be used to break circular de
4
4
  """
5
5
 
6
6
  from contextlib import asynccontextmanager
7
- from typing import Any, AsyncGenerator, Callable, Generic, List, Optional, Protocol, Type, TypeVar
7
+ from typing import (
8
+ Any,
9
+ AsyncGenerator,
10
+ Callable,
11
+ Generic,
12
+ List,
13
+ Optional,
14
+ Protocol,
15
+ Type,
16
+ TypeVar,
17
+ )
8
18
 
9
19
  from mcp import ClientSession
10
20
  from mcp.types import CreateMessageRequestParams
11
21
  from pydantic import Field
12
22
 
23
+ from mcp_agent.mcp.prompt_message_multipart import PromptMessageMultipart
24
+
13
25
 
14
26
  class ServerRegistryProtocol(Protocol):
15
27
  """
@@ -128,13 +140,35 @@ class AugmentedLLMProtocol(Protocol, Generic[MessageParamT, MessageT]):
128
140
  ) -> ModelT:
129
141
  """Request a structured LLM generation and return the result as a Pydantic model."""
130
142
 
143
+ async def generate_prompt(
144
+ self, prompt: PromptMessageMultipart, request_params: RequestParams | None
145
+ ) -> str:
146
+ """Request an LLM generation and return a string representation of the result"""
147
+
148
+ async def apply_prompt(
149
+ self,
150
+ multipart_messages: List["PromptMessageMultipart"],
151
+ request_params: RequestParams | None = None,
152
+ ) -> str:
153
+ """
154
+ Apply a list of PromptMessageMultipart messages directly to the LLM.
155
+ This is a cleaner interface to _apply_prompt_template_provider_specific.
156
+
157
+ Args:
158
+ multipart_messages: List of PromptMessageMultipart objects
159
+ request_params: Optional parameters to configure the LLM request
160
+
161
+ Returns:
162
+ String representation of the assistant's response
163
+ """
164
+
131
165
 
132
166
  class ModelFactoryClassProtocol(Protocol):
133
167
  """
134
168
  Protocol defining the minimal interface of the ModelFactory class needed by sampling.
135
169
  This allows sampling.py to depend on this protocol rather than the concrete ModelFactory class.
136
170
  """
137
-
171
+
138
172
  @classmethod
139
173
  def create_factory(
140
174
  cls, model_string: str, request_params: Optional[RequestParams] = None
@@ -149,4 +183,4 @@ class ModelFactoryClassProtocol(Protocol):
149
183
  Returns:
150
184
  A factory function that can create an LLM instance
151
185
  """
152
- ...
186
+ ...
@@ -123,4 +123,4 @@ class MCPAgentClientSession(ClientSession, ContextDependent):
123
123
  )
124
124
  return await super().send_progress_notification(
125
125
  progress_token=progress_token, progress=progress, total=total
126
- )
126
+ )
@@ -461,8 +461,8 @@ class MCPAggregator(ContextDependent):
461
461
  if server_name is None or local_tool_name is None:
462
462
  logger.error(f"Error: Tool '{name}' not found")
463
463
  return CallToolResult(
464
- isError=True,
465
- content=[TextContent(type="text", text=f"Tool '{name}' not found")]
464
+ isError=True,
465
+ content=[TextContent(type="text", text=f"Tool '{name}' not found")],
466
466
  )
467
467
 
468
468
  logger.info(
@@ -482,8 +482,7 @@ class MCPAggregator(ContextDependent):
482
482
  method_name="call_tool",
483
483
  method_args={"name": local_tool_name, "arguments": arguments},
484
484
  error_factory=lambda msg: CallToolResult(
485
- isError=True,
486
- content=[TextContent(type="text", text=msg)]
485
+ isError=True, content=[TextContent(type="text", text=msg)]
487
486
  ),
488
487
  )
489
488
 
@@ -906,8 +905,8 @@ class MCPCompoundServer(Server):
906
905
  return result.content
907
906
  except Exception as e:
908
907
  return CallToolResult(
909
- isError=True,
910
- content=[TextContent(type="text", text=f"Error calling tool: {e}")]
908
+ isError=True,
909
+ content=[TextContent(type="text", text=f"Error calling tool: {e}")],
911
910
  )
912
911
 
913
912
  async def _get_prompt(
@@ -0,0 +1,140 @@
1
+ """
2
+ This simplified implementation directly converts between MCP types and PromptMessageMultipart.
3
+ """
4
+
5
+ from mcp import ClientSession
6
+ from mcp.types import (
7
+ CreateMessageRequestParams,
8
+ CreateMessageResult,
9
+ )
10
+
11
+ from mcp_agent.core.agent_types import AgentConfig
12
+ from mcp_agent.logging.logger import get_logger
13
+ from mcp_agent.mcp.interfaces import AugmentedLLMProtocol
14
+
15
+ from mcp_agent.workflows.llm.sampling_converter import SamplingConverter
16
+
17
+ logger = get_logger(__name__)
18
+
19
+
20
+ def create_sampling_llm(
21
+ params: CreateMessageRequestParams, model_string: str
22
+ ) -> AugmentedLLMProtocol:
23
+ """
24
+ Create an LLM instance for sampling without tools support.
25
+ This utility function creates a minimal LLM instance based on the model string.
26
+
27
+ Args:
28
+ mcp_ctx: The MCP ClientSession
29
+ model_string: The model to use (e.g. "passthrough", "claude-3-5-sonnet-latest")
30
+
31
+ Returns:
32
+ An initialized LLM instance ready to use
33
+ """
34
+ from mcp_agent.workflows.llm.model_factory import ModelFactory
35
+ from mcp_agent.agents.agent import Agent
36
+
37
+ app_context = None
38
+ try:
39
+ from mcp_agent.context import get_current_context
40
+
41
+ app_context = get_current_context()
42
+ except Exception:
43
+ logger.warning("App context not available for sampling call")
44
+
45
+ agent = Agent(
46
+ config=sampling_agent_config(params),
47
+ context=app_context,
48
+ connection_persistence=False,
49
+ )
50
+
51
+ # Create the LLM using the factory
52
+ factory = ModelFactory.create_factory(model_string)
53
+ llm = factory(agent=agent)
54
+
55
+ # Attach the LLM to the agent
56
+ agent._llm = llm
57
+
58
+ return llm
59
+
60
+
61
+ async def sample(
62
+ mcp_ctx: ClientSession, params: CreateMessageRequestParams
63
+ ) -> CreateMessageResult:
64
+ """
65
+ Handle sampling requests from the MCP protocol using SamplingConverter.
66
+
67
+ This function:
68
+ 1. Extracts the model from the request
69
+ 2. Uses SamplingConverter to convert types
70
+ 3. Calls the LLM's generate_prompt method
71
+ 4. Returns the result as a CreateMessageResult
72
+
73
+ Args:
74
+ mcp_ctx: The MCP ClientSession
75
+ params: The sampling request parameters
76
+
77
+ Returns:
78
+ A CreateMessageResult containing the LLM's response
79
+ """
80
+ model = None
81
+ try:
82
+ # Extract model from server config
83
+ if (
84
+ hasattr(mcp_ctx, "session")
85
+ and hasattr(mcp_ctx.session, "server_config")
86
+ and mcp_ctx.session.server_config
87
+ and hasattr(mcp_ctx.session.server_config, "sampling")
88
+ and mcp_ctx.session.server_config.sampling.model
89
+ ):
90
+ model = mcp_ctx.session.server_config.sampling.model
91
+
92
+ if model is None:
93
+ raise ValueError("No model configured")
94
+
95
+ # Create an LLM instance
96
+ llm = create_sampling_llm(params, model)
97
+
98
+ # Extract all messages from the request params
99
+ if not params.messages:
100
+ raise ValueError("No messages provided")
101
+
102
+ # Convert all SamplingMessages to PromptMessageMultipart objects
103
+ conversation = SamplingConverter.convert_messages(params.messages)
104
+
105
+ # Extract request parameters using our converter
106
+ request_params = SamplingConverter.extract_request_params(params)
107
+
108
+ # Use the new public apply_prompt method which is cleaner than calling the protected method
109
+ llm_response = await llm.apply_prompt(conversation, request_params)
110
+ logger.info(f"Complete sampling request : {llm_response[:50]}...")
111
+
112
+ # Create result using our converter
113
+ return SamplingConverter.create_message_result(
114
+ response=llm_response, model=model
115
+ )
116
+ except Exception as e:
117
+ logger.error(f"Error in sampling: {str(e)}")
118
+ return SamplingConverter.error_result(
119
+ error_message=f"Error in sampling: {str(e)}", model=model
120
+ )
121
+
122
+
123
+ def sampling_agent_config(
124
+ params: CreateMessageRequestParams = None,
125
+ ) -> AgentConfig:
126
+ """
127
+ Build a sampling AgentConfig based on request parameters.
128
+
129
+ Args:
130
+ params: Optional CreateMessageRequestParams that may contain a system prompt
131
+
132
+ Returns:
133
+ An initialized AgentConfig for use in sampling
134
+ """
135
+ # Use systemPrompt from params if available, otherwise use default
136
+ instruction = "You are a helpful AI Agent."
137
+ if params and hasattr(params, "systemPrompt") and params.systemPrompt is not None:
138
+ instruction = params.systemPrompt
139
+
140
+ return AgentConfig(name="sampling_agent", instruction=instruction, servers=[])
@@ -1,4 +1,4 @@
1
1
  # Import and re-export AgentMCPServer to avoid circular imports
2
2
  from mcp_agent.mcp_server.agent_server import AgentMCPServer
3
3
 
4
- __all__ = ["AgentMCPServer"]
4
+ __all__ = ["AgentMCPServer"]
@@ -1,3 +1,3 @@
1
1
  """
2
2
  Prompting examples package for MCP Agent.
3
- """
3
+ """
@@ -250,14 +250,14 @@ class ConsoleDisplay:
250
250
 
251
251
  if agent_name:
252
252
  content.append(f" for {agent_name}", style="cyan italic")
253
-
253
+
254
254
  # Add template arguments if provided
255
255
  if arguments:
256
256
  content.append("\n\nArguments:", style="cyan")
257
257
  for key, value in arguments.items():
258
258
  content.append(f"\n {key}: ", style="cyan bold")
259
259
  content.append(value, style="white")
260
-
260
+
261
261
  if description:
262
262
  content.append("\n\n", style="default")
263
263
  content.append(description, style="dim white")