fast-agent-mcp 0.1.12__py3-none-any.whl → 0.1.13__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.1.12.dist-info → fast_agent_mcp-0.1.13.dist-info}/METADATA +1 -1
- fast_agent_mcp-0.1.13.dist-info/RECORD +164 -0
- mcp_agent/agents/agent.py +37 -79
- mcp_agent/app.py +16 -22
- mcp_agent/cli/commands/bootstrap.py +22 -52
- mcp_agent/cli/commands/config.py +4 -4
- mcp_agent/cli/commands/setup.py +11 -26
- mcp_agent/cli/main.py +6 -9
- mcp_agent/cli/terminal.py +2 -2
- mcp_agent/config.py +1 -5
- mcp_agent/context.py +13 -24
- mcp_agent/context_dependent.py +3 -7
- mcp_agent/core/agent_app.py +45 -121
- mcp_agent/core/agent_utils.py +3 -5
- mcp_agent/core/decorators.py +5 -12
- mcp_agent/core/enhanced_prompt.py +25 -52
- mcp_agent/core/exceptions.py +8 -8
- mcp_agent/core/factory.py +29 -70
- mcp_agent/core/fastagent.py +48 -88
- mcp_agent/core/mcp_content.py +8 -16
- mcp_agent/core/prompt.py +8 -15
- mcp_agent/core/proxies.py +34 -25
- mcp_agent/core/request_params.py +6 -3
- mcp_agent/core/types.py +4 -6
- mcp_agent/core/validation.py +4 -3
- mcp_agent/executor/decorator_registry.py +11 -23
- mcp_agent/executor/executor.py +8 -17
- mcp_agent/executor/task_registry.py +2 -4
- mcp_agent/executor/temporal.py +28 -74
- mcp_agent/executor/workflow.py +3 -5
- mcp_agent/executor/workflow_signal.py +17 -29
- mcp_agent/human_input/handler.py +4 -9
- mcp_agent/human_input/types.py +2 -3
- mcp_agent/logging/events.py +1 -5
- mcp_agent/logging/json_serializer.py +7 -6
- mcp_agent/logging/listeners.py +20 -23
- mcp_agent/logging/logger.py +15 -17
- mcp_agent/logging/rich_progress.py +10 -8
- mcp_agent/logging/tracing.py +4 -6
- mcp_agent/logging/transport.py +22 -22
- mcp_agent/mcp/gen_client.py +4 -12
- mcp_agent/mcp/interfaces.py +71 -86
- mcp_agent/mcp/mcp_agent_client_session.py +11 -19
- mcp_agent/mcp/mcp_agent_server.py +8 -10
- mcp_agent/mcp/mcp_aggregator.py +45 -117
- mcp_agent/mcp/mcp_connection_manager.py +16 -37
- mcp_agent/mcp/prompt_message_multipart.py +12 -18
- mcp_agent/mcp/prompt_serialization.py +13 -38
- mcp_agent/mcp/prompts/prompt_load.py +99 -0
- mcp_agent/mcp/prompts/prompt_server.py +21 -128
- mcp_agent/mcp/prompts/prompt_template.py +20 -42
- mcp_agent/mcp/resource_utils.py +8 -17
- mcp_agent/mcp/sampling.py +5 -14
- mcp_agent/mcp/stdio.py +11 -8
- mcp_agent/mcp_server/agent_server.py +10 -17
- mcp_agent/mcp_server_registry.py +13 -35
- mcp_agent/resources/examples/data-analysis/analysis-campaign.py +1 -1
- mcp_agent/resources/examples/data-analysis/analysis.py +1 -1
- mcp_agent/resources/examples/data-analysis/slides.py +110 -0
- mcp_agent/resources/examples/internal/agent.py +2 -1
- mcp_agent/resources/examples/internal/job.py +2 -1
- mcp_agent/resources/examples/internal/prompt_category.py +1 -1
- mcp_agent/resources/examples/internal/prompt_sizing.py +3 -5
- mcp_agent/resources/examples/internal/sizer.py +2 -1
- mcp_agent/resources/examples/internal/social.py +2 -1
- mcp_agent/resources/examples/mcp_researcher/researcher-eval.py +1 -1
- mcp_agent/resources/examples/prompting/agent.py +2 -1
- mcp_agent/resources/examples/prompting/image_server.py +5 -11
- mcp_agent/resources/examples/researcher/researcher-eval.py +1 -1
- mcp_agent/resources/examples/researcher/researcher-imp.py +3 -4
- mcp_agent/resources/examples/researcher/researcher.py +2 -1
- mcp_agent/resources/examples/workflows/agent_build.py +2 -1
- mcp_agent/resources/examples/workflows/chaining.py +2 -1
- mcp_agent/resources/examples/workflows/evaluator.py +2 -1
- mcp_agent/resources/examples/workflows/human_input.py +2 -1
- mcp_agent/resources/examples/workflows/orchestrator.py +2 -1
- mcp_agent/resources/examples/workflows/parallel.py +2 -1
- mcp_agent/resources/examples/workflows/router.py +2 -1
- mcp_agent/resources/examples/workflows/sse.py +1 -1
- mcp_agent/telemetry/usage_tracking.py +2 -1
- mcp_agent/ui/console_display.py +15 -39
- mcp_agent/workflows/embedding/embedding_base.py +1 -4
- mcp_agent/workflows/embedding/embedding_cohere.py +2 -2
- mcp_agent/workflows/embedding/embedding_openai.py +4 -13
- mcp_agent/workflows/evaluator_optimizer/evaluator_optimizer.py +23 -57
- mcp_agent/workflows/intent_classifier/intent_classifier_base.py +5 -8
- mcp_agent/workflows/intent_classifier/intent_classifier_embedding.py +7 -11
- mcp_agent/workflows/intent_classifier/intent_classifier_embedding_cohere.py +4 -8
- mcp_agent/workflows/intent_classifier/intent_classifier_embedding_openai.py +4 -8
- mcp_agent/workflows/intent_classifier/intent_classifier_llm.py +11 -22
- mcp_agent/workflows/intent_classifier/intent_classifier_llm_anthropic.py +3 -3
- mcp_agent/workflows/intent_classifier/intent_classifier_llm_openai.py +4 -6
- mcp_agent/workflows/llm/anthropic_utils.py +8 -29
- mcp_agent/workflows/llm/augmented_llm.py +69 -247
- mcp_agent/workflows/llm/augmented_llm_anthropic.py +39 -73
- mcp_agent/workflows/llm/augmented_llm_openai.py +42 -97
- mcp_agent/workflows/llm/augmented_llm_passthrough.py +13 -20
- mcp_agent/workflows/llm/augmented_llm_playback.py +8 -6
- mcp_agent/workflows/llm/memory.py +103 -0
- mcp_agent/workflows/llm/model_factory.py +8 -20
- mcp_agent/workflows/llm/openai_utils.py +1 -1
- mcp_agent/workflows/llm/prompt_utils.py +1 -3
- mcp_agent/workflows/llm/providers/multipart_converter_anthropic.py +47 -89
- mcp_agent/workflows/llm/providers/multipart_converter_openai.py +20 -55
- mcp_agent/workflows/llm/providers/openai_multipart.py +19 -61
- mcp_agent/workflows/llm/providers/sampling_converter_anthropic.py +10 -12
- mcp_agent/workflows/llm/providers/sampling_converter_openai.py +7 -11
- mcp_agent/workflows/llm/sampling_converter.py +4 -11
- mcp_agent/workflows/llm/sampling_format_converter.py +12 -12
- mcp_agent/workflows/orchestrator/orchestrator.py +24 -67
- mcp_agent/workflows/orchestrator/orchestrator_models.py +14 -40
- mcp_agent/workflows/parallel/fan_in.py +17 -47
- mcp_agent/workflows/parallel/fan_out.py +6 -12
- mcp_agent/workflows/parallel/parallel_llm.py +9 -26
- mcp_agent/workflows/router/router_base.py +19 -49
- mcp_agent/workflows/router/router_embedding.py +11 -25
- mcp_agent/workflows/router/router_embedding_cohere.py +2 -2
- mcp_agent/workflows/router/router_embedding_openai.py +2 -2
- mcp_agent/workflows/router/router_llm.py +12 -28
- mcp_agent/workflows/swarm/swarm.py +20 -48
- mcp_agent/workflows/swarm/swarm_anthropic.py +2 -2
- mcp_agent/workflows/swarm/swarm_openai.py +2 -2
- fast_agent_mcp-0.1.12.dist-info/RECORD +0 -161
- {fast_agent_mcp-0.1.12.dist-info → fast_agent_mcp-0.1.13.dist-info}/WHEEL +0 -0
- {fast_agent_mcp-0.1.12.dist-info → fast_agent_mcp-0.1.13.dist-info}/entry_points.txt +0 -0
- {fast_agent_mcp-0.1.12.dist-info → fast_agent_mcp-0.1.13.dist-info}/licenses/LICENSE +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.13
|
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
|
@@ -0,0 +1,164 @@
|
|
1
|
+
mcp_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
mcp_agent/app.py,sha256=Y2KymSrh3TcTOGD-oS_QPYyNJ6YpOUTSmP_V-hN74bs,10246
|
3
|
+
mcp_agent/config.py,sha256=IHVhC5fsFklY6lta6z2OI2cGyoT-WDF1_d4NU1sj8Mw,10826
|
4
|
+
mcp_agent/console.py,sha256=Gjf2QLFumwG1Lav__c07X_kZxxEUSkzV-1_-YbAwcwo,813
|
5
|
+
mcp_agent/context.py,sha256=najrCONqeQOI5dFZbne1pHTwzGhV5gdksrddmkO87Aw,7806
|
6
|
+
mcp_agent/context_dependent.py,sha256=m6QqoEoEen2M3Z1ZU3vNqC2x-MypYIqs8gUSadPh21A,1425
|
7
|
+
mcp_agent/event_progress.py,sha256=25iz0yyg-O4glMmtijcYpDdUmtUIKsCmR_8A52GgeC4,2716
|
8
|
+
mcp_agent/mcp_server_registry.py,sha256=8zlO87oTDg7UecQ9-MZriQN34OHTKyQxaTQcILOZbmk,9658
|
9
|
+
mcp_agent/progress_display.py,sha256=GeJU9VUt6qKsFVymG688hCMVCsAygG9ifiiEb5IcbN4,361
|
10
|
+
mcp_agent/agents/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
11
|
+
mcp_agent/agents/agent.py,sha256=0_7AqR3ZjKJEIP7b65I_XLpEUrAal8rHtK22UXlUfws,16350
|
12
|
+
mcp_agent/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
13
|
+
mcp_agent/cli/__main__.py,sha256=AVZ7tQFhU_sDOGuUGJq8ujgKtcxsYJBJwHbVaaiRDlI,166
|
14
|
+
mcp_agent/cli/main.py,sha256=D4EGpUvmyZzqeKfcczOyELzRjXsnB05Cu0otbEv3V2A,2742
|
15
|
+
mcp_agent/cli/terminal.py,sha256=-bUWq21i-hshmvTPAA1eryy12O0LvvoXe9LQJq7k1Sk,1042
|
16
|
+
mcp_agent/cli/commands/bootstrap.py,sha256=TVzruKtO9L3J0tNvqAxkwyMjNd9AAxnUPNKws9StSmQ,10462
|
17
|
+
mcp_agent/cli/commands/config.py,sha256=jU2gl4d5YESrdUboh3u6mxf7CxVT-_DT_sK8Vuh3ajw,231
|
18
|
+
mcp_agent/cli/commands/setup.py,sha256=RsQNWgCLwZokrj15ACEDkTpR4RHtvUzk28WqDcZ5YNY,6233
|
19
|
+
mcp_agent/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
20
|
+
mcp_agent/core/agent_app.py,sha256=zwfQLZrdF6AYQOeUzIGOxfmn3BQWxjYvxMvJ59UZmNQ,27843
|
21
|
+
mcp_agent/core/agent_types.py,sha256=dVOImGJY5xbDFpzLk2Ib4daFsqnm7j06fJN6l34Zwg4,1255
|
22
|
+
mcp_agent/core/agent_utils.py,sha256=4hYdeOml5nX52VCeW7f6KgmfzIh8hHDPPl4QqUMHx3c,1882
|
23
|
+
mcp_agent/core/decorators.py,sha256=hqjMDyApLOZZojXyiBW5KsfhONMcd9QbfHNEYMNko6Y,16072
|
24
|
+
mcp_agent/core/enhanced_prompt.py,sha256=nqny3CG1tgIxR0zQwM-YWS70LFZ8u4uigx5ctD7zXpQ,18518
|
25
|
+
mcp_agent/core/error_handling.py,sha256=xoyS2kLe0eG0bj2eSJCJ2odIhGUve2SbDR7jP-A-uRw,624
|
26
|
+
mcp_agent/core/exceptions.py,sha256=ENAD_qGG67foxy6vDkIvc-lgopIUQy6O7zvNPpPXaQg,2289
|
27
|
+
mcp_agent/core/factory.py,sha256=oNt6WzzCFlQPCRM6NckqCNaeElKgmvbCucJsYpklAw0,18321
|
28
|
+
mcp_agent/core/fastagent.py,sha256=YpK1jO5vpkV50Sb9oV0yIlUvE1Co5mcfzJWLffenbZI,19092
|
29
|
+
mcp_agent/core/mcp_content.py,sha256=-FPG8mDKKuPaw2N-zWlnYFwh7_oAu5RQxKzNdMJ6lhs,6766
|
30
|
+
mcp_agent/core/prompt.py,sha256=wFyJt6J7n-uhJsVCQwaN4ZkzjxA2xFgP5GimN9BTVOc,4238
|
31
|
+
mcp_agent/core/proxies.py,sha256=sMInee2OOb1mTSPwk5jkBUOpXIEqbv66nysOv7k-siU,11072
|
32
|
+
mcp_agent/core/request_params.py,sha256=bEjWo86fqxdiWm2U5nPDd1uCUpcIQO9oiCinhB8lQN0,1185
|
33
|
+
mcp_agent/core/types.py,sha256=GerFhHpupkklPq_w6nGkNyytzTTP9ZJu0fvJIWugEbM,821
|
34
|
+
mcp_agent/core/validation.py,sha256=LZE4OYqUqOYnpv01yxu14V-_nTW2jS6J7WrVK5-Yu7E,8274
|
35
|
+
mcp_agent/eval/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
|
+
mcp_agent/executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
37
|
+
mcp_agent/executor/decorator_registry.py,sha256=LXlmBOSm7QoQV61JIa48qolt2AY0IJy9Tm8Ov6y43VA,3796
|
38
|
+
mcp_agent/executor/executor.py,sha256=MzLSnW9nHrLHYChR3oQa5B8dajQGX26q6-S2BJCxv0o,9507
|
39
|
+
mcp_agent/executor/task_registry.py,sha256=PCALFeYtkQrPBg4RBJnlA0aDI8nHclrNkHGUS4kV3W8,1242
|
40
|
+
mcp_agent/executor/temporal.py,sha256=V-zu1EQxSKpONGzKxlBO8r09cVVW05rLlGa0msKr59s,14576
|
41
|
+
mcp_agent/executor/workflow.py,sha256=T2RzVZ2zD2024zPgQgXERW8zZ3XUv-3dwEeBDZCUkBg,6721
|
42
|
+
mcp_agent/executor/workflow_signal.py,sha256=aOmdkvFbki4hjF0rJZMenvpTYO4jcGAkmV6v-qHcwhw,11116
|
43
|
+
mcp_agent/human_input/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
|
+
mcp_agent/human_input/handler.py,sha256=8D8trAEPDDFZZ_JliZhhY47ALbTgtWEbsYcINWtVb_c,3128
|
45
|
+
mcp_agent/human_input/types.py,sha256=RtWBOVzy8vnYoQrc36jRLn8z8N3C4pDPMBN5vF6qM5Y,1476
|
46
|
+
mcp_agent/logging/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
47
|
+
mcp_agent/logging/events.py,sha256=iHTSgrxK3BWnRoej6NhxVL5899MIHr-ktsA7hxMoo9k,3437
|
48
|
+
mcp_agent/logging/json_serializer.py,sha256=qkfxnR9ka6OgvwSpM2CggELbEtzzkApm0s_KYz11RDY,5791
|
49
|
+
mcp_agent/logging/listeners.py,sha256=_S4Jp5_KWp0kUfrx4BxDdNCeQK3MNT3Zi9AaolPri7A,6648
|
50
|
+
mcp_agent/logging/logger.py,sha256=me1Qt-0qqphpE0zKGQ1zs7Li4FvJERBxrey0C47Y14U,10708
|
51
|
+
mcp_agent/logging/rich_progress.py,sha256=oY9fjb4Tyw6887v8sgO6EGIK4lnmIoR3NNxhA_-Ln_M,4893
|
52
|
+
mcp_agent/logging/tracing.py,sha256=d5lSXakzzi5PtQpUkVkOnYaGX8NduGPq__S7vx-Ln8U,5187
|
53
|
+
mcp_agent/logging/transport.py,sha256=m8YsLLu5T8eof_ndpLQs4gHOzqqEL98xsVwBwDsBfxI,17335
|
54
|
+
mcp_agent/mcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
55
|
+
mcp_agent/mcp/gen_client.py,sha256=ANLTXPerv4srmrED-8y2MeZIB2kMNBLXPmYrYr7_M40,2964
|
56
|
+
mcp_agent/mcp/interfaces.py,sha256=Xxejrr0RV83ghxv75KBkkxI4bU7LWv5ZLv2KCcaKxRY,5251
|
57
|
+
mcp_agent/mcp/mcp_activity.py,sha256=CajXCFWZ2cKEX9s4-HfNVAj471ePTVs4NOkvmIh65tE,592
|
58
|
+
mcp_agent/mcp/mcp_agent_client_session.py,sha256=YSRcXk1dEekOiG6x7YErPQTXGS_VdnyfMvhUz-qaSSQ,4109
|
59
|
+
mcp_agent/mcp/mcp_agent_server.py,sha256=kmXvJQIXbDbeGelcuLqJpJiToFGMQvOD9R_Lju0D_vQ,1613
|
60
|
+
mcp_agent/mcp/mcp_aggregator.py,sha256=VGpnhrSq9IwFHymh4PYIO2cPvhpT177QccNfr2Yx6LM,36596
|
61
|
+
mcp_agent/mcp/mcp_connection_manager.py,sha256=9b5_GCN4LEg-OYbCpgwiP7HLjKAb9ZAZI_2lPmIk1DI,13379
|
62
|
+
mcp_agent/mcp/mime_utils.py,sha256=difepNR_gpb4MpMLkBRAoyhDk-AjXUHTiqKvT_VwS1o,1805
|
63
|
+
mcp_agent/mcp/prompt_message_multipart.py,sha256=qNSQfabqAMUTgfJpKmqtlwyywsNiE_3qrlfdop7xpgI,1930
|
64
|
+
mcp_agent/mcp/prompt_serialization.py,sha256=VtIZU3YCMgbR_PquflncIJZmGTC_8Z3JUuLWPAOovUA,15658
|
65
|
+
mcp_agent/mcp/resource_utils.py,sha256=E8uuIPG1XAA2HSHHJr0Y74bP-l-THryNpgnZRbRL_IA,6582
|
66
|
+
mcp_agent/mcp/sampling.py,sha256=nwd_hvWaOQvhUVvuEgw0IDz6A-7JtpZvPoW8BFu4wys,4457
|
67
|
+
mcp_agent/mcp/stdio.py,sha256=lh2IIqjn4cJ8OE_fyN-HgExjpq5baArOLfbHwHASO9Q,4530
|
68
|
+
mcp_agent/mcp/prompts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
69
|
+
mcp_agent/mcp/prompts/__main__.py,sha256=gr1Tdz9fcK0EXjEuZg_BOnKUmvhYq5AH2lFZicVyNb0,237
|
70
|
+
mcp_agent/mcp/prompts/prompt_load.py,sha256=3iIg1cDRd9Dw-HdcZ66r1TmsbZEW_AkB7oIh1wCtsO4,3798
|
71
|
+
mcp_agent/mcp/prompts/prompt_server.py,sha256=wydIsaiS7QrZUwpqzFLrH42PRnEeWybRxBL_LsIegPs,13958
|
72
|
+
mcp_agent/mcp/prompts/prompt_template.py,sha256=-iU_QCsnbX86d1yYGqwGfn8O_bpMepf-ouAJL5qRn14,16015
|
73
|
+
mcp_agent/mcp_server/__init__.py,sha256=zBU51ITHIEPScd9nRafnhEddsWqXRPAAvHhkrbRI2_4,155
|
74
|
+
mcp_agent/mcp_server/agent_server.py,sha256=lk22tNYJDSGZj5lb8ypyb0S0z194XK0VFFZFs16i4t4,4422
|
75
|
+
mcp_agent/resources/examples/data-analysis/analysis-campaign.py,sha256=BxNSupMPbX5SyKmSTIE4Ze8t6wEoCfkun29QwbqS9Ww,7277
|
76
|
+
mcp_agent/resources/examples/data-analysis/analysis.py,sha256=F2jjJErQZz1GV95M8KF5SlxLUuyqtFm4ZZ87vNeqoJc,2619
|
77
|
+
mcp_agent/resources/examples/data-analysis/fastagent.config.yaml,sha256=ini94PHyJCfgpjcjHKMMbGuHs6LIj46F1NwY0ll5HVk,1609
|
78
|
+
mcp_agent/resources/examples/data-analysis/slides.py,sha256=uFPdVjfhNJvDn9k2TGI3-jzS8n4POORTpQHgnQEOUoU,4914
|
79
|
+
mcp_agent/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv,sha256=pcMeOL1_r8m8MziE6xgbBrQbjl5Ijo98yycZn7O-dlk,227977
|
80
|
+
mcp_agent/resources/examples/internal/agent.py,sha256=pdVfIhD8rRE7058R-aNGlo7bx7aX0LNptWgo04aGBYs,415
|
81
|
+
mcp_agent/resources/examples/internal/fastagent.config.yaml,sha256=U2s0Asc06wC04FstKnBMeB3J5gIa3xa-Rao-1-74XTk,1935
|
82
|
+
mcp_agent/resources/examples/internal/job.py,sha256=ANF3c01gHJ4O4pIxaAtC3rdgYqVObMySaCUBS4dApW4,4102
|
83
|
+
mcp_agent/resources/examples/internal/prompt_category.py,sha256=kMvqNX_zu0sV-kTaAR3skc_tsq9t8QSEofciK0m4aJc,551
|
84
|
+
mcp_agent/resources/examples/internal/prompt_sizing.py,sha256=bskgxulN57hVkc0V9W0fnjnqSRCK5Tkw9Ggf2MmGIVU,1989
|
85
|
+
mcp_agent/resources/examples/internal/sizer.py,sha256=xP1TBJkp4xIdtJnyk2MP4BufThauzULaMmgnt5Y5Iw4,365
|
86
|
+
mcp_agent/resources/examples/internal/social.py,sha256=pTKcpHAcvA-vQYgjVfDuU1FivCR004Nq4N2GXd5OMs0,1716
|
87
|
+
mcp_agent/resources/examples/mcp_researcher/researcher-eval.py,sha256=C1Oz01CP7JlqkWRkHVEt5EJGHTMUqGKEH3AVhTLfyFY,1815
|
88
|
+
mcp_agent/resources/examples/prompting/__init__.py,sha256=2GSrs9MSDIKo-uDrUI0O311F0UH0RW02ZNdvItJzjfI,50
|
89
|
+
mcp_agent/resources/examples/prompting/agent.py,sha256=yuONn6xkQfk6hjanC9j5_zsIK6JtRP7N-tlgVYiKJnE,616
|
90
|
+
mcp_agent/resources/examples/prompting/fastagent.config.yaml,sha256=UR6LtCpeSIzkHsCrHJW1z-wE7AgmgKozS_IYcfcSAkc,1270
|
91
|
+
mcp_agent/resources/examples/prompting/image_server.py,sha256=yuM8ialpKJHD4GKfqoWAsaWjdCjhA4lS77rt7pIGGAk,1661
|
92
|
+
mcp_agent/resources/examples/researcher/fastagent.config.yaml,sha256=bNOnID9OgdSBTUEhdimKB8LjaZLa1B6igmp-nxx8nr4,2271
|
93
|
+
mcp_agent/resources/examples/researcher/researcher-eval.py,sha256=BUUjHDftelmXfnmhNBNijX82-h-RTaVpFl6d3e0ceGE,1826
|
94
|
+
mcp_agent/resources/examples/researcher/researcher-imp.py,sha256=VczElIn-qSOTY9Npi-YypVV9hMz8im-5qfE6-bSxntQ,7872
|
95
|
+
mcp_agent/resources/examples/researcher/researcher.py,sha256=sPYqmBOSopfMQgJZkpo8oFnXMqF7d7XU94BHugwmjQY,1440
|
96
|
+
mcp_agent/resources/examples/workflows/agent_build.py,sha256=uhCvhD9Qb_IxF0UoAzMOtClbi_0YePVifrFncqrXnn8,2864
|
97
|
+
mcp_agent/resources/examples/workflows/chaining.py,sha256=h5o2bQ1vvycmLfnpi0D1gHgSKk0zJPspntWgJ6b8mME,1217
|
98
|
+
mcp_agent/resources/examples/workflows/evaluator.py,sha256=EburhzPFemZCR-5ofFhbWD1aVoL6eZl2CtvOYCrkSgg,3118
|
99
|
+
mcp_agent/resources/examples/workflows/fastagent.config.yaml,sha256=k2AiapOcK42uqG2nWDVvnSLqN4okQIQZK0FTbZufBpY,809
|
100
|
+
mcp_agent/resources/examples/workflows/human_input.py,sha256=-pSiV12fEKupSESI02fH3PuKgisb4dd-bca6sO9G-1A,614
|
101
|
+
mcp_agent/resources/examples/workflows/orchestrator.py,sha256=kBFU-v6cW26RRlOiEiH6TMLL2KvYDBa_BSwJgHHKoao,2605
|
102
|
+
mcp_agent/resources/examples/workflows/parallel.py,sha256=TJ4MnAf9vNuDhLfSgJ-66n7jV2kO-Xhr-rWufKukpnQ,3105
|
103
|
+
mcp_agent/resources/examples/workflows/router.py,sha256=E4x_-c3l4YW9w1i4ARcDtkdeqIdbWEGfsMzwLYpdbVc,1677
|
104
|
+
mcp_agent/resources/examples/workflows/sse.py,sha256=iv6hpdLiMdGUaw3pu8ceR1PV7nTItN3nUkTkQ_HN85Q,578
|
105
|
+
mcp_agent/telemetry/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
106
|
+
mcp_agent/telemetry/usage_tracking.py,sha256=aa-me9jusF7ovBSn9PG_RxvDnMRblsGKGn-AgNA8RkQ,510
|
107
|
+
mcp_agent/ui/console_display.py,sha256=bldOSYv0RtbN-QyxtKAodNLqTZW6pxY91pKUj81SWio,9368
|
108
|
+
mcp_agent/workflows/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
109
|
+
mcp_agent/workflows/embedding/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
110
|
+
mcp_agent/workflows/embedding/embedding_base.py,sha256=DoanBbdoQFOFvv_aNihLJ5yXG2xizi9KHaOnP72UY50,1674
|
111
|
+
mcp_agent/workflows/embedding/embedding_cohere.py,sha256=sZWoL7ZOkyakpkzZTFbKzXzfuyyFKwLNn7n5WZY0uDA,1548
|
112
|
+
mcp_agent/workflows/embedding/embedding_openai.py,sha256=RHqJsEpG3v1cxhupo1BINoFasHfxUTZt0T9ZMIbxtUk,1384
|
113
|
+
mcp_agent/workflows/evaluator_optimizer/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
114
|
+
mcp_agent/workflows/evaluator_optimizer/evaluator_optimizer.py,sha256=yil4pzjnj5OCA6JerMSQTHDdpNr86hDjcz54iWYlo5U,17640
|
115
|
+
mcp_agent/workflows/intent_classifier/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
116
|
+
mcp_agent/workflows/intent_classifier/intent_classifier_base.py,sha256=e2iNZOnHvP5rjYMs60L9PgyDJyHuhF_IgG6iUTZQlAU,3993
|
117
|
+
mcp_agent/workflows/intent_classifier/intent_classifier_embedding.py,sha256=WcZB76E-Zpcy6cPlUUvq_n3O0YxsvmApRH3whJYiRQo,3969
|
118
|
+
mcp_agent/workflows/intent_classifier/intent_classifier_embedding_cohere.py,sha256=GC3d0pg0ic21tLsegeJ7MDfuYJbOGn6RTE-2vh2fYHo,1504
|
119
|
+
mcp_agent/workflows/intent_classifier/intent_classifier_embedding_openai.py,sha256=QTZ69JNoIqGACz_2ejbByQkVsciZwWB6W5LzSdZoqZo,1504
|
120
|
+
mcp_agent/workflows/intent_classifier/intent_classifier_llm.py,sha256=ghKMNL1Pgm4bcQe5KK31atE_fDF_n2utckQqCVtapOs,5034
|
121
|
+
mcp_agent/workflows/intent_classifier/intent_classifier_llm_anthropic.py,sha256=PkCUeUGJ3fV3_UI1_utmIE3CKi0Fr7RXi0CgZFBh-Ik,1972
|
122
|
+
mcp_agent/workflows/intent_classifier/intent_classifier_llm_openai.py,sha256=vK-VfU36Sp_TxUcOSVYBlMBFQ7GzlP3QFXAYanIUX-c,1926
|
123
|
+
mcp_agent/workflows/llm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
124
|
+
mcp_agent/workflows/llm/anthropic_utils.py,sha256=xHQ7Dt0co88m02lvGiKZdj3p75dVPyI8SQvWe71HBe0,3195
|
125
|
+
mcp_agent/workflows/llm/augmented_llm.py,sha256=47bBW-Nwx_GHp6zsw524L_A5KIpg4coUI9IilFZYquE,23411
|
126
|
+
mcp_agent/workflows/llm/augmented_llm_anthropic.py,sha256=pS245nFqA2fiHk7a0Y1NcMg3fx3ckqRAfpC8uMbCm54,19593
|
127
|
+
mcp_agent/workflows/llm/augmented_llm_openai.py,sha256=5Nay-3fPLqWNSuhKWf3Rs-q9uStloEupkujfqfKHAsE,20177
|
128
|
+
mcp_agent/workflows/llm/augmented_llm_passthrough.py,sha256=2qJusYzoFK0kTsF7G0KFJiHDfcOK1o_nhIeO9RQwB8o,8862
|
129
|
+
mcp_agent/workflows/llm/augmented_llm_playback.py,sha256=XdxGwuNJKFyvVt1WhnbrwX0Ax9Wg5Hs1TuzJ6WAScJw,4362
|
130
|
+
mcp_agent/workflows/llm/memory.py,sha256=UakoBCJBf59JBtB6uyZM0OZjlxDW_VHtSfDs08ibVEc,3312
|
131
|
+
mcp_agent/workflows/llm/model_factory.py,sha256=tngHscO1-pTZPspHju_I_O7trypyR25k13RFOyc3tUw,7571
|
132
|
+
mcp_agent/workflows/llm/openai_utils.py,sha256=nJpyaYdS5Ovmcj73es7t4LpE4ontxjDYbwqNcmEWR6w,1895
|
133
|
+
mcp_agent/workflows/llm/prompt_utils.py,sha256=yWQHykoK13QRF7evHUKxVF0SpVLN-Bsft0Yixzvn0g0,4825
|
134
|
+
mcp_agent/workflows/llm/sampling_converter.py,sha256=KlR6jnmkbDy_o8uDuAdS2kzIv8a8MKJ3_RithPs5MSc,3591
|
135
|
+
mcp_agent/workflows/llm/sampling_format_converter.py,sha256=7FrJi2HaV9czrL4H2wkfF8TsR-Xn119RPNP-aa8QDE8,767
|
136
|
+
mcp_agent/workflows/llm/providers/__init__.py,sha256=qirdqAKIbw3BY1NBdGytH9tvpjOu0QNOqKAG2deD_U4,285
|
137
|
+
mcp_agent/workflows/llm/providers/multipart_converter_anthropic.py,sha256=5MkuEVI86WwSg6wfOrFY-6_d2LKQMZnHEQolnOfrHxk,15727
|
138
|
+
mcp_agent/workflows/llm/providers/multipart_converter_openai.py,sha256=hy9rsq320nct36mXzZ5tYdN5RGrMtw9E4OCVe4pPsik,16459
|
139
|
+
mcp_agent/workflows/llm/providers/openai_multipart.py,sha256=cvosYOI1dPI6p9lrk5D-TpgRrXcHFy9PD_lKE9wIgHg,6589
|
140
|
+
mcp_agent/workflows/llm/providers/sampling_converter_anthropic.py,sha256=h3j6np65p1eW86XiEsnjLcc7V2KAz3pzT-ayvrJZyf8,1632
|
141
|
+
mcp_agent/workflows/llm/providers/sampling_converter_openai.py,sha256=Wqxy7eXNx3oJKfNKG9BiJiqR14S8xaz9y1YygfjN1io,841
|
142
|
+
mcp_agent/workflows/orchestrator/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
143
|
+
mcp_agent/workflows/orchestrator/orchestrator.py,sha256=1HDOtOonfCsqeK_Bqp3G5JwWClCEzEN22-oNcfcLU2w,21483
|
144
|
+
mcp_agent/workflows/orchestrator/orchestrator_models.py,sha256=M5sFH6JlneNaBXiD7L-rQYKn8yJgM8vDsX6ampmXz5U,7113
|
145
|
+
mcp_agent/workflows/orchestrator/orchestrator_prompts.py,sha256=EXKEI174sshkZyPPEnWbwwNafzSPuA39MXL7iqG9cWc,9106
|
146
|
+
mcp_agent/workflows/parallel/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
147
|
+
mcp_agent/workflows/parallel/fan_in.py,sha256=IKxQGvzR6oE-Z3KZ2a5AndaOwIH87JcbYTpZ15LFZnE,12804
|
148
|
+
mcp_agent/workflows/parallel/fan_out.py,sha256=LSOjwUaQj-mB3ldjtpR6LNHjsspvdxGSCn1AiIO-OO0,6957
|
149
|
+
mcp_agent/workflows/parallel/parallel_llm.py,sha256=VRcBXW_TvT-PAGniffzVAtZZPKgl1mIBBH4bgI59DtY,5601
|
150
|
+
mcp_agent/workflows/router/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
151
|
+
mcp_agent/workflows/router/router_base.py,sha256=9D5W9_rqB_nnPU1S1YpGcFjsrBlagGY0T2MA7kLIznc,13908
|
152
|
+
mcp_agent/workflows/router/router_embedding.py,sha256=GBCakhNIQL3GJhHPsCOqm4EfR7G27Ijw3Pyk-7hyHtI,7814
|
153
|
+
mcp_agent/workflows/router/router_embedding_cohere.py,sha256=xZImdyymuYvP08z304Z1CoUkCvAKL4xOS5TW7IOwB9M,1983
|
154
|
+
mcp_agent/workflows/router/router_embedding_openai.py,sha256=w7qoOc8jM1XxP6-1GAK3ZI1Noy4B00vYrw_R9zmKiuU,1983
|
155
|
+
mcp_agent/workflows/router/router_llm.py,sha256=JwtEoKiEmnoY08ue8vV_6kJY0FdlbbnzgUWVmEsbHBs,10778
|
156
|
+
mcp_agent/workflows/swarm/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
157
|
+
mcp_agent/workflows/swarm/swarm.py,sha256=y3TiH_leHPDDOxFmynfBxs1N2NkB_4wwXYur4TYr400,10774
|
158
|
+
mcp_agent/workflows/swarm/swarm_anthropic.py,sha256=tgbG9lERqAcRPSFBB85ewxlz1C01KZsCEkFUoGvPbw0,1624
|
159
|
+
mcp_agent/workflows/swarm/swarm_openai.py,sha256=653ILzYcJUnlequKDv03_wCRt83AH5sn2QKPAC60opE,1596
|
160
|
+
fast_agent_mcp-0.1.13.dist-info/METADATA,sha256=5_QyvfF957PGwZPdrO8I5FXyQut0KkXoOthPdRpQgSU,29678
|
161
|
+
fast_agent_mcp-0.1.13.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
162
|
+
fast_agent_mcp-0.1.13.dist-info/entry_points.txt,sha256=qPM7vwtN1_KmP3dXehxgiCxUBHtqP7yfenZigztvY-w,226
|
163
|
+
fast_agent_mcp-0.1.13.dist-info/licenses/LICENSE,sha256=cN3FxDURL9XuzE5mhK9L2paZo82LTfjwCYVT7e3j0e4,10939
|
164
|
+
fast_agent_mcp-0.1.13.dist-info/RECORD,,
|
mcp_agent/agents/agent.py
CHANGED
@@ -1,29 +1,30 @@
|
|
1
1
|
import asyncio
|
2
2
|
import uuid
|
3
|
-
from typing import Callable, Dict, List, Optional, TypeVar, Union
|
3
|
+
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, TypeVar, Union
|
4
4
|
|
5
5
|
from mcp.server.fastmcp.tools import Tool as FastTool
|
6
6
|
from mcp.types import (
|
7
7
|
CallToolResult,
|
8
|
+
EmbeddedResource,
|
8
9
|
ListToolsResult,
|
10
|
+
ReadResourceResult,
|
9
11
|
TextContent,
|
10
12
|
Tool,
|
11
|
-
EmbeddedResource,
|
12
|
-
ReadResourceResult,
|
13
13
|
)
|
14
|
-
from mcp_agent.mcp.prompt_message_multipart import PromptMessageMultipart
|
15
14
|
|
16
|
-
from mcp_agent.core.exceptions import PromptExitError
|
17
|
-
from mcp_agent.mcp.mcp_aggregator import MCPAggregator
|
18
15
|
from mcp_agent.core.agent_types import AgentConfig
|
16
|
+
from mcp_agent.core.exceptions import PromptExitError
|
17
|
+
from mcp_agent.core.request_params import RequestParams
|
19
18
|
from mcp_agent.human_input.types import (
|
19
|
+
HUMAN_INPUT_SIGNAL_NAME,
|
20
20
|
HumanInputCallback,
|
21
21
|
HumanInputRequest,
|
22
22
|
HumanInputResponse,
|
23
|
-
HUMAN_INPUT_SIGNAL_NAME,
|
24
23
|
)
|
25
|
-
from mcp_agent.workflows.llm.augmented_llm import AugmentedLLM
|
26
24
|
from mcp_agent.logging.logger import get_logger
|
25
|
+
from mcp_agent.mcp.mcp_aggregator import MCPAggregator
|
26
|
+
from mcp_agent.mcp.prompt_message_multipart import PromptMessageMultipart
|
27
|
+
from mcp_agent.workflows.llm.augmented_llm import AugmentedLLMProtocol
|
27
28
|
|
28
29
|
if TYPE_CHECKING:
|
29
30
|
from mcp_agent.context import Context
|
@@ -32,7 +33,7 @@ import traceback
|
|
32
33
|
logger = get_logger(__name__)
|
33
34
|
|
34
35
|
# Define a TypeVar for AugmentedLLM and its subclasses
|
35
|
-
LLM = TypeVar("LLM", bound=
|
36
|
+
LLM = TypeVar("LLM", bound=AugmentedLLMProtocol)
|
36
37
|
|
37
38
|
HUMAN_INPUT_TOOL_NAME = "__human_input__"
|
38
39
|
|
@@ -45,17 +46,15 @@ class Agent(MCPAggregator):
|
|
45
46
|
|
46
47
|
def __init__(
|
47
48
|
self,
|
48
|
-
config: Union[
|
49
|
-
AgentConfig, str
|
50
|
-
], # Can be AgentConfig or backward compatible str name
|
49
|
+
config: Union[AgentConfig, str], # Can be AgentConfig or backward compatible str name
|
51
50
|
instruction: Optional[Union[str, Callable[[Dict], str]]] = None,
|
52
51
|
server_names: Optional[List[str]] = None,
|
53
52
|
functions: Optional[List[Callable]] = None,
|
54
53
|
connection_persistence: bool = True,
|
55
54
|
human_input_callback: Optional[HumanInputCallback] = None,
|
56
55
|
context: Optional["Context"] = None,
|
57
|
-
**kwargs,
|
58
|
-
):
|
56
|
+
**kwargs: dict[str, Any],
|
57
|
+
) -> None:
|
59
58
|
# Handle backward compatibility where first arg was name
|
60
59
|
if isinstance(config, str):
|
61
60
|
self.config = AgentConfig(
|
@@ -94,14 +93,12 @@ class Agent(MCPAggregator):
|
|
94
93
|
if self.context.human_input_handler:
|
95
94
|
self.human_input_callback = self.context.human_input_handler
|
96
95
|
|
97
|
-
async def initialize(self):
|
96
|
+
async def initialize(self) -> None:
|
98
97
|
"""
|
99
98
|
Initialize the agent and connect to the MCP servers.
|
100
99
|
NOTE: This method is called automatically when the agent is used as an async context manager.
|
101
100
|
"""
|
102
|
-
await (
|
103
|
-
self.__aenter__()
|
104
|
-
) # This initializes the connection manager and loads the servers
|
101
|
+
await self.__aenter__() # This initializes the connection manager and loads the servers
|
105
102
|
|
106
103
|
for function in self.functions:
|
107
104
|
tool: FastTool = FastTool.from_function(function)
|
@@ -119,11 +116,9 @@ class Agent(MCPAggregator):
|
|
119
116
|
Returns:
|
120
117
|
An instance of AugmentedLLM or one of its subclasses.
|
121
118
|
"""
|
122
|
-
return llm_factory(
|
123
|
-
agent=self, default_request_params=self._default_request_params
|
124
|
-
)
|
119
|
+
return llm_factory(agent=self, default_request_params=self._default_request_params)
|
125
120
|
|
126
|
-
async def shutdown(self):
|
121
|
+
async def shutdown(self) -> None:
|
127
122
|
"""
|
128
123
|
Shutdown the agent and close all MCP server connections.
|
129
124
|
NOTE: This method is called automatically when the agent is used as an async context manager.
|
@@ -153,8 +148,9 @@ class Agent(MCPAggregator):
|
|
153
148
|
request.metadata = {"agent_name": self.name}
|
154
149
|
self.logger.debug("Requesting human input:", data=request)
|
155
150
|
|
156
|
-
async def call_callback_and_signal():
|
151
|
+
async def call_callback_and_signal() -> None:
|
157
152
|
try:
|
153
|
+
assert self.human_input_callback is not None
|
158
154
|
user_input = await self.human_input_callback(request)
|
159
155
|
|
160
156
|
self.logger.debug("Received human input:", data=user_input)
|
@@ -167,9 +163,7 @@ class Agent(MCPAggregator):
|
|
167
163
|
payload={"exit_requested": True, "error": str(e)},
|
168
164
|
)
|
169
165
|
except Exception as e:
|
170
|
-
await self.executor.signal(
|
171
|
-
request_id, payload=f"Error getting human input: {str(e)}"
|
172
|
-
)
|
166
|
+
await self.executor.signal(request_id, payload=f"Error getting human input: {str(e)}")
|
173
167
|
|
174
168
|
asyncio.create_task(call_callback_and_signal())
|
175
169
|
|
@@ -186,9 +180,7 @@ class Agent(MCPAggregator):
|
|
186
180
|
)
|
187
181
|
|
188
182
|
if isinstance(result, dict) and result.get("exit_requested", False):
|
189
|
-
raise PromptExitError(
|
190
|
-
result.get("error", "User requested to exit FastAgent session")
|
191
|
-
)
|
183
|
+
raise PromptExitError(result.get("error", "User requested to exit FastAgent session"))
|
192
184
|
self.logger.debug("Received human input signal", data=result)
|
193
185
|
return result
|
194
186
|
|
@@ -226,9 +218,7 @@ class Agent(MCPAggregator):
|
|
226
218
|
return result
|
227
219
|
|
228
220
|
# todo would prefer to use tool_name to disambiguate agent name
|
229
|
-
async def call_tool(
|
230
|
-
self, name: str, arguments: dict | None = None
|
231
|
-
) -> CallToolResult:
|
221
|
+
async def call_tool(self, name: str, arguments: dict | None = None) -> CallToolResult:
|
232
222
|
if name == HUMAN_INPUT_TOOL_NAME:
|
233
223
|
# Call the human input tool
|
234
224
|
return await self._call_human_input_tool(arguments)
|
@@ -240,9 +230,7 @@ class Agent(MCPAggregator):
|
|
240
230
|
else:
|
241
231
|
return await super().call_tool(name, arguments)
|
242
232
|
|
243
|
-
async def _call_human_input_tool(
|
244
|
-
self, arguments: dict | None = None
|
245
|
-
) -> CallToolResult:
|
233
|
+
async def _call_human_input_tool(self, arguments: dict | None = None) -> CallToolResult:
|
246
234
|
# Handle human input request
|
247
235
|
try:
|
248
236
|
# Make sure arguments is not None
|
@@ -264,17 +252,9 @@ class Agent(MCPAggregator):
|
|
264
252
|
result = await self.request_human_input(request=request)
|
265
253
|
|
266
254
|
# Use response attribute if available, otherwise use the result directly
|
267
|
-
response_text = (
|
268
|
-
result.response
|
269
|
-
if isinstance(result, HumanInputResponse)
|
270
|
-
else str(result)
|
271
|
-
)
|
255
|
+
response_text = result.response if isinstance(result, HumanInputResponse) else str(result)
|
272
256
|
|
273
|
-
return CallToolResult(
|
274
|
-
content=[
|
275
|
-
TextContent(type="text", text=f"Human response: {response_text}")
|
276
|
-
]
|
277
|
-
)
|
257
|
+
return CallToolResult(content=[TextContent(type="text", text=f"Human response: {response_text}")])
|
278
258
|
|
279
259
|
except PromptExitError:
|
280
260
|
raise
|
@@ -293,21 +273,10 @@ class Agent(MCPAggregator):
|
|
293
273
|
|
294
274
|
return CallToolResult(
|
295
275
|
isError=True,
|
296
|
-
content=[
|
297
|
-
TextContent(
|
298
|
-
type="text", text=f"Error requesting human input: {str(e)}"
|
299
|
-
)
|
300
|
-
],
|
276
|
+
content=[TextContent(type="text", text=f"Error requesting human input: {str(e)}")],
|
301
277
|
)
|
302
278
|
|
303
|
-
async def
|
304
|
-
self, server_name: str, resource_name: str
|
305
|
-
) -> ReadResourceResult:
|
306
|
-
return None
|
307
|
-
|
308
|
-
async def apply_prompt(
|
309
|
-
self, prompt_name: str, arguments: dict[str, str] = None
|
310
|
-
) -> str:
|
279
|
+
async def apply_prompt(self, prompt_name: str, arguments: dict[str, str] | None) -> str:
|
311
280
|
"""
|
312
281
|
Apply an MCP Server Prompt by name and return the assistant's response.
|
313
282
|
Will search all available servers for the prompt if not namespaced.
|
@@ -331,9 +300,7 @@ class Agent(MCPAggregator):
|
|
331
300
|
prompt_result = await self.get_prompt(prompt_name, arguments)
|
332
301
|
|
333
302
|
if not prompt_result or not prompt_result.messages:
|
334
|
-
error_msg =
|
335
|
-
f"Prompt '{prompt_name}' could not be found or contains no messages"
|
336
|
-
)
|
303
|
+
error_msg = f"Prompt '{prompt_name}' could not be found or contains no messages"
|
337
304
|
self.logger.warning(error_msg)
|
338
305
|
return error_msg
|
339
306
|
|
@@ -372,16 +339,10 @@ class Agent(MCPAggregator):
|
|
372
339
|
resource_result = await server.get_resource(resource_name)
|
373
340
|
return resource_result
|
374
341
|
except Exception as e:
|
375
|
-
self.logger.error(
|
376
|
-
|
377
|
-
)
|
378
|
-
raise ValueError(
|
379
|
-
f"Failed to retrieve resource '{resource_name}' from server '{server_name}': {str(e)}"
|
380
|
-
)
|
342
|
+
self.logger.error(f"Error retrieving resource '{resource_name}' from server '{server_name}': {str(e)}")
|
343
|
+
raise ValueError(f"Failed to retrieve resource '{resource_name}' from server '{server_name}': {str(e)}")
|
381
344
|
|
382
|
-
async def get_embedded_resources(
|
383
|
-
self, server_name: str, resource_name: str
|
384
|
-
) -> List[EmbeddedResource]:
|
345
|
+
async def get_embedded_resources(self, server_name: str, resource_name: str) -> List[EmbeddedResource]:
|
385
346
|
"""
|
386
347
|
Get a resource from an MCP server and return it as a list of embedded resources ready for use in prompts.
|
387
348
|
|
@@ -396,20 +357,19 @@ class Agent(MCPAggregator):
|
|
396
357
|
ValueError: If the server doesn't exist or the resource couldn't be found
|
397
358
|
"""
|
398
359
|
# Get the raw resource result
|
399
|
-
result: ReadResourceResult = await super().get_resource(
|
400
|
-
server_name, resource_name
|
401
|
-
)
|
360
|
+
result: ReadResourceResult = await super().get_resource(server_name, resource_name)
|
402
361
|
|
403
362
|
# Convert each resource content to an EmbeddedResource
|
404
363
|
embedded_resources: List[EmbeddedResource] = []
|
405
364
|
for resource_content in result.contents:
|
406
|
-
embedded_resource = EmbeddedResource(
|
407
|
-
type="resource", resource=resource_content, annotations=None
|
408
|
-
)
|
365
|
+
embedded_resource = EmbeddedResource(type="resource", resource=resource_content, annotations=None)
|
409
366
|
embedded_resources.append(embedded_resource)
|
410
367
|
|
411
368
|
return embedded_resources
|
412
369
|
|
370
|
+
async def apply_prompt_messages(self, prompts: List[PromptMessageMultipart], request_params: RequestParams | None) -> str:
|
371
|
+
return self._llm.apply_prompt_messages(prompts, request_params)
|
372
|
+
|
413
373
|
async def with_resource(
|
414
374
|
self,
|
415
375
|
prompt_content: Union[str, PromptMessageMultipart],
|
@@ -428,9 +388,7 @@ class Agent(MCPAggregator):
|
|
428
388
|
The agent's response as a string
|
429
389
|
"""
|
430
390
|
# Get the embedded resources
|
431
|
-
embedded_resources: List[EmbeddedResource] = await self.get_embedded_resources(
|
432
|
-
server_name, resource_name
|
433
|
-
)
|
391
|
+
embedded_resources: List[EmbeddedResource] = await self.get_embedded_resources(server_name, resource_name)
|
434
392
|
|
435
393
|
# Create or update the prompt message
|
436
394
|
prompt: PromptMessageMultipart
|
mcp_agent/app.py
CHANGED
@@ -1,16 +1,18 @@
|
|
1
|
-
from typing import Any, Dict, Optional, Type, TypeVar, Callable
|
2
|
-
from datetime import timedelta
|
3
1
|
import asyncio
|
4
2
|
from contextlib import asynccontextmanager
|
3
|
+
from datetime import timedelta
|
4
|
+
from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Type, TypeVar
|
5
5
|
|
6
|
-
from mcp import ServerSession
|
7
|
-
from mcp_agent.context import Context, initialize_context, cleanup_context
|
8
6
|
from mcp_agent.config import Settings
|
7
|
+
from mcp_agent.context import Context, cleanup_context, initialize_context
|
9
8
|
from mcp_agent.event_progress import ProgressAction
|
10
|
-
from mcp_agent.logging.logger import get_logger
|
11
9
|
from mcp_agent.executor.workflow_signal import SignalWaitCallback
|
12
|
-
from mcp_agent.human_input.types import HumanInputCallback
|
13
10
|
from mcp_agent.human_input.handler import console_input_callback
|
11
|
+
from mcp_agent.human_input.types import HumanInputCallback
|
12
|
+
from mcp_agent.logging.logger import get_logger
|
13
|
+
|
14
|
+
if TYPE_CHECKING:
|
15
|
+
from mcp import ServerSession
|
14
16
|
|
15
17
|
R = TypeVar("R")
|
16
18
|
|
@@ -43,7 +45,7 @@ class MCPApp:
|
|
43
45
|
human_input_callback: Optional[HumanInputCallback] = console_input_callback,
|
44
46
|
signal_notification: Optional[SignalWaitCallback] = None,
|
45
47
|
upstream_session: Optional["ServerSession"] = None,
|
46
|
-
):
|
48
|
+
) -> None:
|
47
49
|
"""
|
48
50
|
Initialize the application with a name and optional settings.
|
49
51
|
Args:
|
@@ -70,9 +72,7 @@ class MCPApp:
|
|
70
72
|
@property
|
71
73
|
def context(self) -> Context:
|
72
74
|
if self._context is None:
|
73
|
-
raise RuntimeError(
|
74
|
-
"MCPApp not initialized, please call initialize() first, or use async with app.run()."
|
75
|
-
)
|
75
|
+
raise RuntimeError("MCPApp not initialized, please call initialize() first, or use async with app.run().")
|
76
76
|
return self._context
|
77
77
|
|
78
78
|
@property
|
@@ -96,7 +96,7 @@ class MCPApp:
|
|
96
96
|
return self._context.upstream_session
|
97
97
|
|
98
98
|
@upstream_session.setter
|
99
|
-
def upstream_session(self, value):
|
99
|
+
def upstream_session(self, value) -> None:
|
100
100
|
self._context.upstream_session = value
|
101
101
|
|
102
102
|
@property
|
@@ -113,7 +113,7 @@ class MCPApp:
|
|
113
113
|
self._logger = get_logger(f"mcp_agent.{self.name}")
|
114
114
|
return self._logger
|
115
115
|
|
116
|
-
async def initialize(self):
|
116
|
+
async def initialize(self) -> None:
|
117
117
|
"""Initialize the application."""
|
118
118
|
if self._initialized:
|
119
119
|
return
|
@@ -135,7 +135,7 @@ class MCPApp:
|
|
135
135
|
},
|
136
136
|
)
|
137
137
|
|
138
|
-
async def cleanup(self):
|
138
|
+
async def cleanup(self) -> None:
|
139
139
|
"""Cleanup application resources."""
|
140
140
|
if not self._initialized:
|
141
141
|
return
|
@@ -173,9 +173,7 @@ class MCPApp:
|
|
173
173
|
finally:
|
174
174
|
await self.cleanup()
|
175
175
|
|
176
|
-
def workflow(
|
177
|
-
self, cls: Type, *args, workflow_id: str | None = None, **kwargs
|
178
|
-
) -> Type:
|
176
|
+
def workflow(self, cls: Type, *args, workflow_id: str | None = None, **kwargs) -> Type:
|
179
177
|
"""
|
180
178
|
Decorator for a workflow class. By default it's a no-op,
|
181
179
|
but different executors can use this to customize behavior
|
@@ -187,9 +185,7 @@ class MCPApp:
|
|
187
185
|
"""
|
188
186
|
decorator_registry = self.context.decorator_registry
|
189
187
|
execution_engine = self.engine
|
190
|
-
workflow_defn_decorator = decorator_registry.get_workflow_defn_decorator(
|
191
|
-
execution_engine
|
192
|
-
)
|
188
|
+
workflow_defn_decorator = decorator_registry.get_workflow_defn_decorator(execution_engine)
|
193
189
|
|
194
190
|
if workflow_defn_decorator:
|
195
191
|
return workflow_defn_decorator(cls, *args, **kwargs)
|
@@ -211,9 +207,7 @@ class MCPApp:
|
|
211
207
|
|
212
208
|
decorator_registry = self.context.decorator_registry
|
213
209
|
execution_engine = self.engine
|
214
|
-
workflow_run_decorator = decorator_registry.get_workflow_run_decorator(
|
215
|
-
execution_engine
|
216
|
-
)
|
210
|
+
workflow_run_decorator = decorator_registry.get_workflow_run_decorator(execution_engine)
|
217
211
|
|
218
212
|
if workflow_run_decorator:
|
219
213
|
return workflow_run_decorator(fn)
|