fast-agent-mcp 0.1.13__py3-none-any.whl → 0.2.0__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.
Files changed (147) hide show
  1. {fast_agent_mcp-0.1.13.dist-info → fast_agent_mcp-0.2.0.dist-info}/METADATA +3 -4
  2. fast_agent_mcp-0.2.0.dist-info/RECORD +123 -0
  3. mcp_agent/__init__.py +75 -0
  4. mcp_agent/agents/agent.py +59 -371
  5. mcp_agent/agents/base_agent.py +522 -0
  6. mcp_agent/agents/workflow/__init__.py +1 -0
  7. mcp_agent/agents/workflow/chain_agent.py +173 -0
  8. mcp_agent/agents/workflow/evaluator_optimizer.py +362 -0
  9. mcp_agent/agents/workflow/orchestrator_agent.py +591 -0
  10. mcp_agent/{workflows/orchestrator → agents/workflow}/orchestrator_models.py +27 -11
  11. mcp_agent/agents/workflow/parallel_agent.py +182 -0
  12. mcp_agent/agents/workflow/router_agent.py +307 -0
  13. mcp_agent/app.py +3 -1
  14. mcp_agent/cli/commands/bootstrap.py +18 -7
  15. mcp_agent/cli/commands/setup.py +12 -4
  16. mcp_agent/cli/main.py +1 -1
  17. mcp_agent/cli/terminal.py +1 -1
  18. mcp_agent/config.py +24 -35
  19. mcp_agent/context.py +3 -1
  20. mcp_agent/context_dependent.py +3 -1
  21. mcp_agent/core/agent_types.py +10 -7
  22. mcp_agent/core/direct_agent_app.py +179 -0
  23. mcp_agent/core/direct_decorators.py +443 -0
  24. mcp_agent/core/direct_factory.py +476 -0
  25. mcp_agent/core/enhanced_prompt.py +15 -20
  26. mcp_agent/core/fastagent.py +151 -337
  27. mcp_agent/core/interactive_prompt.py +424 -0
  28. mcp_agent/core/mcp_content.py +19 -11
  29. mcp_agent/core/prompt.py +6 -2
  30. mcp_agent/core/validation.py +89 -16
  31. mcp_agent/executor/decorator_registry.py +6 -2
  32. mcp_agent/executor/temporal.py +35 -11
  33. mcp_agent/executor/workflow_signal.py +8 -2
  34. mcp_agent/human_input/handler.py +3 -1
  35. mcp_agent/llm/__init__.py +2 -0
  36. mcp_agent/{workflows/llm → llm}/augmented_llm.py +131 -256
  37. mcp_agent/{workflows/llm → llm}/augmented_llm_passthrough.py +35 -107
  38. mcp_agent/llm/augmented_llm_playback.py +83 -0
  39. mcp_agent/{workflows/llm → llm}/model_factory.py +26 -8
  40. mcp_agent/llm/providers/__init__.py +8 -0
  41. mcp_agent/{workflows/llm → llm/providers}/anthropic_utils.py +5 -1
  42. mcp_agent/{workflows/llm → llm/providers}/augmented_llm_anthropic.py +37 -141
  43. mcp_agent/llm/providers/augmented_llm_deepseek.py +53 -0
  44. mcp_agent/{workflows/llm → llm/providers}/augmented_llm_openai.py +112 -148
  45. mcp_agent/{workflows/llm → llm}/providers/multipart_converter_anthropic.py +78 -35
  46. mcp_agent/{workflows/llm → llm}/providers/multipart_converter_openai.py +73 -44
  47. mcp_agent/{workflows/llm → llm}/providers/openai_multipart.py +18 -4
  48. mcp_agent/{workflows/llm → llm/providers}/openai_utils.py +3 -3
  49. mcp_agent/{workflows/llm → llm}/providers/sampling_converter_anthropic.py +3 -3
  50. mcp_agent/{workflows/llm → llm}/providers/sampling_converter_openai.py +3 -3
  51. mcp_agent/{workflows/llm → llm}/sampling_converter.py +0 -21
  52. mcp_agent/{workflows/llm → llm}/sampling_format_converter.py +16 -1
  53. mcp_agent/logging/logger.py +2 -2
  54. mcp_agent/mcp/gen_client.py +9 -3
  55. mcp_agent/mcp/interfaces.py +67 -45
  56. mcp_agent/mcp/logger_textio.py +97 -0
  57. mcp_agent/mcp/mcp_agent_client_session.py +12 -4
  58. mcp_agent/mcp/mcp_agent_server.py +3 -1
  59. mcp_agent/mcp/mcp_aggregator.py +124 -93
  60. mcp_agent/mcp/mcp_connection_manager.py +21 -7
  61. mcp_agent/mcp/prompt_message_multipart.py +59 -1
  62. mcp_agent/mcp/prompt_render.py +77 -0
  63. mcp_agent/mcp/prompt_serialization.py +20 -13
  64. mcp_agent/mcp/prompts/prompt_constants.py +18 -0
  65. mcp_agent/mcp/prompts/prompt_helpers.py +327 -0
  66. mcp_agent/mcp/prompts/prompt_load.py +15 -5
  67. mcp_agent/mcp/prompts/prompt_server.py +154 -87
  68. mcp_agent/mcp/prompts/prompt_template.py +26 -35
  69. mcp_agent/mcp/resource_utils.py +3 -1
  70. mcp_agent/mcp/sampling.py +24 -15
  71. mcp_agent/mcp_server/agent_server.py +8 -5
  72. mcp_agent/mcp_server_registry.py +22 -9
  73. mcp_agent/resources/examples/{workflows → in_dev}/agent_build.py +1 -1
  74. mcp_agent/resources/examples/{data-analysis → in_dev}/slides.py +1 -1
  75. mcp_agent/resources/examples/internal/agent.py +4 -2
  76. mcp_agent/resources/examples/internal/fastagent.config.yaml +8 -2
  77. mcp_agent/resources/examples/prompting/image_server.py +3 -1
  78. mcp_agent/resources/examples/prompting/work_with_image.py +19 -0
  79. mcp_agent/ui/console_display.py +27 -7
  80. fast_agent_mcp-0.1.13.dist-info/RECORD +0 -164
  81. mcp_agent/core/agent_app.py +0 -570
  82. mcp_agent/core/agent_utils.py +0 -69
  83. mcp_agent/core/decorators.py +0 -448
  84. mcp_agent/core/factory.py +0 -422
  85. mcp_agent/core/proxies.py +0 -278
  86. mcp_agent/core/types.py +0 -22
  87. mcp_agent/eval/__init__.py +0 -0
  88. mcp_agent/mcp/stdio.py +0 -114
  89. mcp_agent/resources/examples/data-analysis/analysis-campaign.py +0 -188
  90. mcp_agent/resources/examples/data-analysis/analysis.py +0 -65
  91. mcp_agent/resources/examples/data-analysis/fastagent.config.yaml +0 -41
  92. mcp_agent/resources/examples/data-analysis/mount-point/WA_Fn-UseC_-HR-Employee-Attrition.csv +0 -1471
  93. mcp_agent/resources/examples/mcp_researcher/researcher-eval.py +0 -53
  94. mcp_agent/resources/examples/researcher/fastagent.config.yaml +0 -66
  95. mcp_agent/resources/examples/researcher/researcher-eval.py +0 -53
  96. mcp_agent/resources/examples/researcher/researcher-imp.py +0 -189
  97. mcp_agent/resources/examples/researcher/researcher.py +0 -39
  98. mcp_agent/resources/examples/workflows/chaining.py +0 -45
  99. mcp_agent/resources/examples/workflows/evaluator.py +0 -79
  100. mcp_agent/resources/examples/workflows/fastagent.config.yaml +0 -24
  101. mcp_agent/resources/examples/workflows/human_input.py +0 -26
  102. mcp_agent/resources/examples/workflows/orchestrator.py +0 -74
  103. mcp_agent/resources/examples/workflows/parallel.py +0 -79
  104. mcp_agent/resources/examples/workflows/router.py +0 -54
  105. mcp_agent/resources/examples/workflows/sse.py +0 -23
  106. mcp_agent/telemetry/__init__.py +0 -0
  107. mcp_agent/telemetry/usage_tracking.py +0 -19
  108. mcp_agent/workflows/__init__.py +0 -0
  109. mcp_agent/workflows/embedding/__init__.py +0 -0
  110. mcp_agent/workflows/embedding/embedding_base.py +0 -58
  111. mcp_agent/workflows/embedding/embedding_cohere.py +0 -49
  112. mcp_agent/workflows/embedding/embedding_openai.py +0 -37
  113. mcp_agent/workflows/evaluator_optimizer/__init__.py +0 -0
  114. mcp_agent/workflows/evaluator_optimizer/evaluator_optimizer.py +0 -447
  115. mcp_agent/workflows/intent_classifier/__init__.py +0 -0
  116. mcp_agent/workflows/intent_classifier/intent_classifier_base.py +0 -117
  117. mcp_agent/workflows/intent_classifier/intent_classifier_embedding.py +0 -130
  118. mcp_agent/workflows/intent_classifier/intent_classifier_embedding_cohere.py +0 -41
  119. mcp_agent/workflows/intent_classifier/intent_classifier_embedding_openai.py +0 -41
  120. mcp_agent/workflows/intent_classifier/intent_classifier_llm.py +0 -150
  121. mcp_agent/workflows/intent_classifier/intent_classifier_llm_anthropic.py +0 -60
  122. mcp_agent/workflows/intent_classifier/intent_classifier_llm_openai.py +0 -58
  123. mcp_agent/workflows/llm/__init__.py +0 -0
  124. mcp_agent/workflows/llm/augmented_llm_playback.py +0 -111
  125. mcp_agent/workflows/llm/providers/__init__.py +0 -8
  126. mcp_agent/workflows/orchestrator/__init__.py +0 -0
  127. mcp_agent/workflows/orchestrator/orchestrator.py +0 -535
  128. mcp_agent/workflows/parallel/__init__.py +0 -0
  129. mcp_agent/workflows/parallel/fan_in.py +0 -320
  130. mcp_agent/workflows/parallel/fan_out.py +0 -181
  131. mcp_agent/workflows/parallel/parallel_llm.py +0 -149
  132. mcp_agent/workflows/router/__init__.py +0 -0
  133. mcp_agent/workflows/router/router_base.py +0 -338
  134. mcp_agent/workflows/router/router_embedding.py +0 -226
  135. mcp_agent/workflows/router/router_embedding_cohere.py +0 -59
  136. mcp_agent/workflows/router/router_embedding_openai.py +0 -59
  137. mcp_agent/workflows/router/router_llm.py +0 -304
  138. mcp_agent/workflows/swarm/__init__.py +0 -0
  139. mcp_agent/workflows/swarm/swarm.py +0 -292
  140. mcp_agent/workflows/swarm/swarm_anthropic.py +0 -42
  141. mcp_agent/workflows/swarm/swarm_openai.py +0 -41
  142. {fast_agent_mcp-0.1.13.dist-info → fast_agent_mcp-0.2.0.dist-info}/WHEEL +0 -0
  143. {fast_agent_mcp-0.1.13.dist-info → fast_agent_mcp-0.2.0.dist-info}/entry_points.txt +0 -0
  144. {fast_agent_mcp-0.1.13.dist-info → fast_agent_mcp-0.2.0.dist-info}/licenses/LICENSE +0 -0
  145. /mcp_agent/{workflows/orchestrator → agents/workflow}/orchestrator_prompts.py +0 -0
  146. /mcp_agent/{workflows/llm → llm}/memory.py +0 -0
  147. /mcp_agent/{workflows/llm → llm}/prompt_utils.py +0 -0
@@ -1,53 +0,0 @@
1
- import asyncio
2
-
3
- from mcp_agent.core.fastagent import FastAgent
4
-
5
- agents = FastAgent(name="Researcher")
6
-
7
-
8
- @agents.agent(
9
- name="Researcher",
10
- instruction="""
11
- You are a research assistant, with access to internet search (via Brave),
12
- website fetch, a python interpreter (you can install packages with uv) and a filesystem.
13
- Use the current working directory to save and create files with both the Interpreter and Filesystem tools.
14
- The interpreter has numpy, pandas, matplotlib and seaborn already installed.
15
-
16
- You must always provide a summary of the specific sources you have used in your research.
17
- """,
18
- servers=["brave", "interpreter", "filesystem", "fetch"],
19
- )
20
- @agents.agent(
21
- name="Evaluator",
22
- model="sonnet",
23
- instruction="""
24
- Evaluate the response from the researcher based on the criteria:
25
- - Sources cited. Has the researcher provided a summary of the specific sources used in the research?
26
- - Validity. Has the researcher cross-checked and validated data and assumptions.
27
- - Alignment. Has the researher acted and addressed feedback from any previous assessments?
28
-
29
- For each criterion:
30
- - Provide a rating (EXCELLENT, GOOD, FAIR, or POOR).
31
- - Offer specific feedback or suggestions for improvement.
32
-
33
- Summarize your evaluation as a structured response with:
34
- - Overall quality rating.
35
- - Specific feedback and areas for improvement.""",
36
- )
37
- @agents.evaluator_optimizer(
38
- generator="Researcher",
39
- evaluator="Evaluator",
40
- max_refinements=5,
41
- min_rating="EXCELLENT",
42
- name="Researcher_Evaluator",
43
- )
44
- async def main() -> None:
45
- async with agents.run() as agent:
46
- await agent.prompt("Researcher_Evaluator")
47
-
48
- print("Ask follow up quesions to the Researcher?")
49
- await agent.prompt("Researcher", default="STOP")
50
-
51
-
52
- if __name__ == "__main__":
53
- asyncio.run(main())
@@ -1,66 +0,0 @@
1
- #
2
- # Please edit this configuration file to match your environment (on Windows).
3
- # Examples in comments below - check/change the paths.
4
- #
5
- #
6
-
7
- execution_engine: asyncio
8
- logger:
9
- type: console
10
- level: error
11
- truncate_tools: true
12
-
13
- mcp:
14
- servers:
15
- brave:
16
- # On windows replace the command and args line to use `node` and the absolute path to the server.
17
- # Use `npm i -g @modelcontextprotocol/server-brave-search` to install the server globally.
18
- # Use `npm -g root` to find the global node_modules path.`
19
- # command: "node"
20
- # args: ["c:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-brave-search/dist/index.js"]
21
- command: "npx"
22
- args: ["-y", "@modelcontextprotocol/server-brave-search"]
23
- env:
24
- # You can also place your BRAVE_API_KEY in the fastagent.secrets.yaml file.
25
- BRAVE_API_KEY: <your_brave_api_key>
26
- filesystem:
27
- # On windows update the command and arguments to use `node` and the absolute path to the server.
28
- # Use `npm i -g @modelcontextprotocol/server-filesystem` to install the server globally.
29
- # Use `npm -g root` to find the global node_modules path.`
30
- # command: "node"
31
- # args: ["c:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js","./agent_folder"]
32
- command: "npx"
33
- args: ["-y", "@modelcontextprotocol/server-filesystem", "./agent_folder/"]
34
- interpreter:
35
- command: "docker"
36
- args: [
37
- "run",
38
- "-i",
39
- "--rm",
40
- "--pull=always",
41
- "-v",
42
- "./agent_folder:/mnt/data/",
43
- # Docker needs the absolute path on Windows (e.g. "x:/fastagent/agent_folder:/mnt/data/")
44
- # "./agent_folder:/mnt/data/",
45
- "ghcr.io/evalstate/mcp-py-repl:latest",
46
- ]
47
- roots:
48
- - uri: "file://./agent_folder/"
49
- name: "agent_folder"
50
- server_uri_alias: "file:///mnt/data/"
51
- fetch:
52
- command: "uvx"
53
- args: ["mcp-server-fetch"]
54
- sequential:
55
- command: "npx"
56
- args: ["-y","@modelcontextprotocol/server-sequential-thinking"]
57
-
58
- # webmcp:
59
- # command: "node"
60
- # args: ["/home/ssmith/.webmcp/server.cjs"]
61
- # env:
62
- # WEBMCP_SERVER_TOKEN: 96e22896d8143fc1d61fec09208fc5ed
63
-
64
-
65
-
66
-
@@ -1,53 +0,0 @@
1
- import asyncio
2
-
3
- from mcp_agent.core.fastagent import FastAgent
4
-
5
- agents = FastAgent(name="Researcher Agent (EO)")
6
-
7
-
8
- @agents.agent(
9
- name="Researcher",
10
- instruction="""
11
- You are a research assistant, with access to internet search (via Brave),
12
- website fetch, a python interpreter (you can install packages with uv) and a filesystem.
13
- Use the current working directory to save and create files with both the Interpreter and Filesystem tools.
14
- The interpreter has numpy, pandas, matplotlib and seaborn already installed.
15
-
16
- You must always provide a summary of the specific sources you have used in your research.
17
- """,
18
- servers=["brave", "interpreter", "filesystem", "fetch"],
19
- )
20
- @agents.agent(
21
- name="Evaluator",
22
- model="sonnet",
23
- instruction="""
24
- Evaluate the response from the researcher based on the criteria:
25
- - Sources cited. Has the researcher provided a summary of the specific sources used in the research?
26
- - Validity. Has the researcher cross-checked and validated data and assumptions.
27
- - Alignment. Has the researher acted and addressed feedback from any previous assessments?
28
-
29
- For each criterion:
30
- - Provide a rating (EXCELLENT, GOOD, FAIR, or POOR).
31
- - Offer specific feedback or suggestions for improvement.
32
-
33
- Summarize your evaluation as a structured response with:
34
- - Overall quality rating.
35
- - Specific feedback and areas for improvement.""",
36
- )
37
- @agents.evaluator_optimizer(
38
- generator="Researcher",
39
- evaluator="Evaluator",
40
- max_refinements=5,
41
- min_rating="EXCELLENT",
42
- name="Researcher_Evaluator",
43
- )
44
- async def main() -> None:
45
- async with agents.run() as agent:
46
- await agent.prompt("Researcher_Evaluator")
47
-
48
- print("Ask follow up quesions to the Researcher?")
49
- await agent.prompt("Researcher", default="STOP")
50
-
51
-
52
- if __name__ == "__main__":
53
- asyncio.run(main())
@@ -1,189 +0,0 @@
1
- import asyncio
2
-
3
- from mcp_agent.core.fastagent import FastAgent
4
-
5
- agents = FastAgent(name="Enhanced Researcher")
6
-
7
-
8
- @agents.agent(
9
- name="ResearchPlanner",
10
- model="sonnet", # Using a more capable model for planning
11
- instruction="""
12
- You are a strategic research planner. Your job is to:
13
- 1. Break down complex research questions into specific sub-questions
14
- 2. Identify the key information sources needed to answer each sub-question
15
- 3. Outline a structured research plan
16
-
17
- When given a research topic:
18
- - Analyze what is being asked and identify the core components
19
- - Define 3-5 specific sub-questions that need to be answered
20
- - For each sub-question, suggest specific search queries and information sources
21
- - Prioritize the most important areas to investigate first
22
- - Include suggestions for data visualization or analysis if appropriate
23
-
24
- Your output should be a clear, structured research plan that the Researcher can follow.
25
- """,
26
- servers=["brave"],
27
- )
28
- @agents.agent(
29
- name="Researcher",
30
- model="sonnet", # Using a more capable model for deep research
31
- instruction="""
32
- You are an expert research assistant with access to multiple resources:
33
- - Brave Search for initial exploration and discovering sources
34
- - Website fetching to read and extract information directly from webpages
35
- - Python interpreter for data analysis and visualization
36
- - Filesystem tools to save and organize your findings
37
-
38
- RESEARCH METHODOLOGY:
39
- 1. First understand the research plan provided
40
- 2. For each sub-question, use search tools to find multiple relevant sources
41
- 3. Go beyond surface-level information by:
42
- - Consulting primary sources when possible
43
- - Cross-referencing information across multiple sources
44
- - Using the fetch tool to access complete articles rather than just search snippets
45
- - Analyzing data with Python when numerical evidence is needed
46
- - Creating visualizations when they help clarify complex information
47
-
48
- CRITICAL INFORMATION ASSESSMENT:
49
- - Evaluate the credibility of each source (consider recency, authority, potential bias)
50
- - Look for consensus across multiple sources
51
- - Highlight any contradictions or areas of debate in the research
52
- - Clearly state limitations in the available information
53
-
54
- DOCUMENTATION:
55
- - Save important information, data, and visualizations to files
56
- - Always create a comprehensive bibliography with links to all sources
57
- - Include specific citation details (author, date, publication) when available
58
- - Note which specific information came from which source
59
-
60
- FINAL RESPONSE:
61
- - Structure your findings logically with clear headings
62
- - Synthesize the information rather than just listing facts
63
- - Directly address each sub-question from the research plan
64
- - Use data and visualizations to support key points
65
- - End with a concise executive summary of your findings
66
- - Include a "Methodology" section explaining how you conducted your research
67
- """,
68
- servers=["brave", "interpreter", "filesystem", "fetch"],
69
- use_history=True,
70
- )
71
- @agents.agent(
72
- name="FactChecker",
73
- instruction="""
74
- You are a meticulous fact-checker and critical evaluator of research. Your responsibilities are to:
75
-
76
- 1. Verify factual claims by cross-checking with authoritative sources
77
- 2. Identify any unsupported assertions or logical fallacies
78
- 3. Detect potential biases or limitations in the research methodology
79
- 4. Ensure proper representation of diverse perspectives on controversial topics
80
- 5. Evaluate the quality, reliability, and currency of cited sources
81
-
82
- When reviewing research:
83
- - Flag any claims that lack sufficient evidence or citation
84
- - Identify information that seems outdated or contradicts current consensus
85
- - Check for oversimplifications of complex topics
86
- - Ensure numerical data and statistics are accurately represented
87
- - Verify that quotations are accurate and in proper context
88
- - Look for any gaps in the research or important perspectives that were omitted
89
-
90
- Your feedback should be specific, actionable, and structured to help improve accuracy and comprehensiveness.
91
- """,
92
- servers=["brave", "fetch"],
93
- )
94
- @agents.agent(
95
- name="Evaluator",
96
- model="sonnet",
97
- instruction="""
98
- You are a senior research quality evaluator with expertise in academic and professional research standards.
99
-
100
- COMPREHENSIVE EVALUATION CRITERIA:
101
- 1. Research Methodology
102
- - Has the researcher followed a structured approach?
103
- - Were appropriate research methods applied?
104
- - Is there evidence of strategic information gathering?
105
-
106
- 2. Source Quality & Diversity
107
- - Are sources authoritative, current, and relevant?
108
- - Is there appropriate diversity of sources?
109
- - Were primary sources consulted when appropriate?
110
-
111
- 3. Information Depth
112
- - Does the research go beyond surface-level information?
113
- - Is there evidence of in-depth analysis?
114
- - Has the researcher explored multiple aspects of the topic?
115
-
116
- 4. Critical Analysis
117
- - Has information been critically evaluated rather than simply reported?
118
- - Are limitations and uncertainties acknowledged?
119
- - Are multiple perspectives considered on controversial topics?
120
-
121
- 5. Data & Evidence
122
- - Is quantitative data properly analyzed and presented?
123
- - Are visualizations clear, accurate, and informative?
124
- - Is qualitative information presented with appropriate context?
125
-
126
- 6. Documentation & Attribution
127
- - Are all sources properly cited with complete reference information?
128
- - Is it clear which information came from which source?
129
- - Is the bibliography comprehensive and well-formatted?
130
-
131
- 7. Structure & Communication
132
- - Is the research presented in a logical, well-organized manner?
133
- - Are findings communicated clearly and precisely?
134
- - Is the level of technical language appropriate for the intended audience?
135
-
136
- 8. Alignment with Previous Feedback
137
- - Has the researcher addressed specific feedback from previous evaluations?
138
- - Have requested improvements been successfully implemented?
139
-
140
- For each criterion, provide:
141
- - A detailed RATING (EXCELLENT, GOOD, FAIR, or POOR)
142
- - Specific examples from the research that justify your rating
143
- - Clear, actionable suggestions for improvement
144
-
145
- Your evaluation should conclude with:
146
- - An OVERALL RATING that reflects the research quality
147
- - A concise summary of the research's major strengths
148
- - A prioritized list of the most important areas for improvement
149
-
150
- The researcher should be able to understand exactly why they received their rating and what specific steps they can take to improve.
151
- """,
152
- )
153
- @agents.chain(
154
- name="ResearchProcess",
155
- sequence=["ResearchPlanner", "Researcher", "FactChecker"],
156
- instruction="A comprehensive research workflow that plans, executes, and verifies research",
157
- cumulative=True,
158
- )
159
- @agents.evaluator_optimizer(
160
- generator="ResearchProcess",
161
- evaluator="Evaluator",
162
- max_refinements=3,
163
- min_rating="EXCELLENT",
164
- name="EnhancedResearcher",
165
- )
166
- async def main() -> None:
167
- async with agents.run() as agent:
168
- # Start with a warm-up to set expectations and explain the research approach
169
- await agent.Researcher.send(
170
- """I'm an enhanced research assistant trained to conduct thorough, evidence-based research.
171
- I'll approach your question by:
172
- 1. Creating a structured research plan
173
- 2. Gathering information from multiple authoritative sources
174
- 3. Analyzing data and creating visualizations when helpful
175
- 4. Fact-checking and verifying all information
176
- 5. Providing a comprehensive, well-documented answer
177
-
178
- What would you like me to research for you today?"""
179
- )
180
-
181
- # Start the main research workflow
182
- await agent.prompt("EnhancedResearcher")
183
-
184
- print("\nWould you like to ask follow-up questions to the Researcher? (Type 'STOP' to end)")
185
- await agent.prompt("Researcher", default="STOP")
186
-
187
-
188
- if __name__ == "__main__":
189
- asyncio.run(main())
@@ -1,39 +0,0 @@
1
- import asyncio
2
-
3
- from mcp_agent.core.fastagent import FastAgent
4
-
5
- # from rich import print
6
-
7
- agents = FastAgent(name="Researcher Agent")
8
-
9
-
10
- @agents.agent(
11
- "Researcher",
12
- instruction="""
13
- You are a research assistant, with access to internet search (via Brave),
14
- website fetch, a python interpreter (you can install packages with uv) and a filesystem.
15
- Use the current working directory to save and create files with both the Interpreter and Filesystem tools.
16
- The interpreter has numpy, pandas, matplotlib and seaborn already installed
17
- """,
18
- servers=["brave", "interpreter", "filesystem", "fetch"],
19
- )
20
- async def main() -> None:
21
- research_prompt = """
22
- Produce an investment report for the company Eutelsat. The final report should be saved in the filesystem in markdown format, and
23
- contain at least the following:
24
- 1 - A brief description of the company
25
- 2 - Current financial position (find data, create and incorporate charts)
26
- 3 - A PESTLE analysis
27
- 4 - An investment thesis for the next 3 years. Include both 'buy side' and 'sell side' arguments, and a final
28
- summary and recommendation.
29
- Todays date is 15 February 2025. Include the main data sources consulted in presenting the report.""" # noqa: F841
30
-
31
- async with agents.run() as agent:
32
- await agent.prompt()
33
-
34
- # await agent.prompt(default="STOP")
35
- # await agent.prompt(default=research_prompt)
36
-
37
-
38
- if __name__ == "__main__":
39
- asyncio.run(main())
@@ -1,45 +0,0 @@
1
- import asyncio
2
-
3
- from mcp_agent.core.fastagent import FastAgent
4
-
5
- # Create the application
6
- fast = FastAgent("Agent Chaining")
7
-
8
-
9
- @fast.agent(
10
- "url_fetcher",
11
- instruction="Given a URL, provide a complete and comprehensive summary",
12
- servers=["fetch"],
13
- )
14
- @fast.agent(
15
- "social_media",
16
- instruction="""
17
- Write a 280 character social media post for any given text.
18
- Respond only with the post, never use hashtags.
19
- """,
20
- )
21
- @fast.chain(
22
- name="post_writer",
23
- sequence=["url_fetcher", "social_media"],
24
- )
25
- async def main() -> None:
26
- async with fast.run() as agent:
27
- # using chain workflow
28
- await agent.post_writer.prompt()
29
-
30
- # calling directly
31
- # await agent.url_fetcher("http://llmindset.co.uk/resources/mcp-hfspace/")
32
- # await agent.social_media(
33
- # await agent.url_fetcher("http://llmindset.co.uk/resources/mcp-hfspace/")
34
- # )
35
-
36
- # agents can also be accessed like dictionaries:
37
- # awwait agent["post_writer"].prompt()
38
-
39
-
40
- # alternative syntax for above is result = agent["post_writer"].send(message)
41
- # alternative syntax for above is result = agent["post_writer"].prompt()
42
-
43
-
44
- if __name__ == "__main__":
45
- asyncio.run(main())
@@ -1,79 +0,0 @@
1
- """
2
- This demonstrates creating an optimizer and evaluator to iteratively improve content.
3
- """
4
-
5
- import asyncio
6
-
7
- from mcp_agent.core.fastagent import FastAgent
8
-
9
- # Create the application
10
- fast = FastAgent("Evaluator-Optimizer")
11
-
12
-
13
- # Define generator agent
14
- @fast.agent(
15
- name="generator",
16
- instruction="""You are a career coach specializing in cover letter writing.
17
- You are tasked with generating a compelling cover letter given the job posting,
18
- candidate details, and company information. Tailor the response to the company and job requirements.
19
- """,
20
- servers=["fetch"],
21
- model="haiku3",
22
- use_history=True,
23
- )
24
- # Define evaluator agent
25
- @fast.agent(
26
- name="evaluator",
27
- instruction="""Evaluate the following response based on the criteria below:
28
- 1. Clarity: Is the language clear, concise, and grammatically correct?
29
- 2. Specificity: Does the response include relevant and concrete details tailored to the job description?
30
- 3. Relevance: Does the response align with the prompt and avoid unnecessary information?
31
- 4. Tone and Style: Is the tone professional and appropriate for the context?
32
- 5. Persuasiveness: Does the response effectively highlight the candidate's value?
33
- 6. Grammar and Mechanics: Are there any spelling or grammatical issues?
34
- 7. Feedback Alignment: Has the response addressed feedback from previous iterations?
35
-
36
- For each criterion:
37
- - Provide a rating (EXCELLENT, GOOD, FAIR, or POOR).
38
- - Offer specific feedback or suggestions for improvement.
39
-
40
- Summarize your evaluation as a structured response with:
41
- - Overall quality rating.
42
- - Specific feedback and areas for improvement.""",
43
- model="gpt-4o",
44
- )
45
- # Define the evaluator-optimizer workflow
46
- @fast.evaluator_optimizer(
47
- name="cover_letter_writer",
48
- generator="generator", # Reference to generator agent
49
- evaluator="evaluator", # Reference to evaluator agent
50
- min_rating="EXCELLENT", # Strive for excellence
51
- max_refinements=3, # Maximum iterations
52
- )
53
- async def main() -> None:
54
- async with fast.run() as agent:
55
- job_posting = (
56
- "Software Engineer at LastMile AI. Responsibilities include developing AI systems, "
57
- "collaborating with cross-functional teams, and enhancing scalability. Skills required: "
58
- "Python, distributed systems, and machine learning."
59
- )
60
- candidate_details = (
61
- "Alex Johnson, 3 years in machine learning, contributor to open-source AI projects, "
62
- "proficient in Python and TensorFlow. Motivated by building scalable AI systems to solve real-world problems."
63
- )
64
- company_information = (
65
- "Look up from the LastMile AI About page: https://lastmileai.dev/about"
66
- )
67
-
68
- # Send the task
69
- await agent.cover_letter_writer.send(
70
- f"Write a cover letter for the following job posting: {job_posting}\n\n"
71
- f"Candidate Details: {candidate_details}\n\n"
72
- f"Company information: {company_information}",
73
- )
74
-
75
- await agent()
76
-
77
-
78
- if __name__ == "__main__":
79
- asyncio.run(main())
@@ -1,24 +0,0 @@
1
- # Please edit this configuration file to match your environment (on Windows).
2
- # Examples in comments below - check/change the paths.
3
- #
4
- #
5
-
6
- execution_engine: asyncio
7
- logger:
8
- type: file
9
- level: error
10
- truncate_tools: true
11
-
12
- mcp:
13
- servers:
14
- filesystem:
15
- # On windows update the command and arguments to use `node` and the absolute path to the server.
16
- # Use `npm i -g @modelcontextprotocol/server-filesystem` to install the server globally.
17
- # Use `npm -g root` to find the global node_modules path.`
18
- # command: "node"
19
- # args: ["c:/Program Files/nodejs/node_modules/@modelcontextprotocol/server-filesystem/dist/index.js","."]
20
- command: "npx"
21
- args: ["-y", "@modelcontextprotocol/server-filesystem", "."]
22
- fetch:
23
- command: "uvx"
24
- args: ["mcp-server-fetch"]
@@ -1,26 +0,0 @@
1
- """
2
- Agent which demonstrates Human Input tool
3
- """
4
-
5
- import asyncio
6
-
7
- from mcp_agent.core.fastagent import FastAgent
8
-
9
- # Create the application
10
- fast = FastAgent("Human Input")
11
-
12
-
13
- # Define the agent
14
- @fast.agent(
15
- instruction="An AI agent that assists with basic tasks. Request Human Input when needed.",
16
- human_input=True,
17
- )
18
- async def main() -> None:
19
- async with fast.run() as agent:
20
- # this usually causes the LLM to request the Human Input Tool
21
- await agent("print the next number in the sequence")
22
- await agent.prompt(default="STOP")
23
-
24
-
25
- if __name__ == "__main__":
26
- asyncio.run(main())
@@ -1,74 +0,0 @@
1
- """
2
- This demonstrates creating multiple agents and an orchestrator to coordinate them.
3
- """
4
-
5
- import asyncio
6
-
7
- from mcp_agent.core.fastagent import FastAgent
8
-
9
- # Create the application
10
- fast = FastAgent("Orchestrator-Workers")
11
-
12
-
13
- @fast.agent(
14
- "author",
15
- instruction="""You are to role play a poorly skilled writer,
16
- who makes frequent grammar, punctuations and spelling errors. You enjoy
17
- writing short stories, but the narrative doesn't always make sense""",
18
- servers=["filesystem"],
19
- )
20
- # Define worker agents
21
- @fast.agent(
22
- name="finder",
23
- instruction="""You are an agent with access to the filesystem,
24
- as well as the ability to fetch URLs. Your job is to identify
25
- the closest match to a user's request, make the appropriate tool calls,
26
- and return the URI and CONTENTS of the closest match.""",
27
- servers=["fetch", "filesystem"],
28
- model="gpt-4o",
29
- )
30
- @fast.agent(
31
- name="writer",
32
- instruction="""You are an agent that can write to the filesystem.
33
- You are tasked with taking the user's input, addressing it, and
34
- writing the result to disk in the appropriate location.""",
35
- servers=["filesystem"],
36
- )
37
- @fast.agent(
38
- name="proofreader",
39
- instruction=""""Review the short story for grammar, spelling, and punctuation errors.
40
- Identify any awkward phrasing or structural issues that could improve clarity.
41
- Provide detailed feedback on corrections.""",
42
- servers=["fetch"],
43
- model="gpt-4o",
44
- )
45
- # Define the orchestrator to coordinate the other agents
46
- @fast.orchestrator(
47
- name="orchestrate",
48
- agents=["finder", "writer", "proofreader"],
49
- plan_type="iterative",
50
- )
51
- async def main() -> None:
52
- async with fast.run() as agent:
53
- await agent()
54
- await agent.author(
55
- "write a 250 word short story about kittens discovering a castle, and save it to short_story.md"
56
- )
57
-
58
- # The orchestrator can be used just like any other agent
59
- task = (
60
- """Load the student's short story from short_story.md,
61
- and generate a report with feedback across proofreading,
62
- factuality/logical consistency and style adherence. Use the style rules from
63
- https://apastyle.apa.org/learn/quick-guide-on-formatting and
64
- https://apastyle.apa.org/learn/quick-guide-on-references.
65
- Write the graded report to graded_report.md in the same directory as short_story.md""",
66
- )
67
-
68
- # Send the task
69
- await agent.orchestrate(task)
70
- await agent()
71
-
72
-
73
- if __name__ == "__main__":
74
- asyncio.run(main())