Skip to content

Commit 5ebd1d8

Browse files
committed
Added ability for people to add names and desriptions to their MCP agents in the secret they provide. Also, working to successfully merge develop template.yaml into mine without conflicts
1 parent b3c96cb commit 5ebd1d8

File tree

4 files changed

+780
-243
lines changed

4 files changed

+780
-243
lines changed

docs/custom-MCP-agent.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,9 @@ In the AWS account where the IDP solution is deployed, create a secret with your
159159
"cognito_user_pool_id": "us-east-1_XXXXXXXXX",
160160
"cognito_client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
161161
"cognito_username": "mcp-service-user-1",
162-
"cognito_password": "SecurePassword123!"
162+
"cognito_password": "SecurePassword123!",
163+
"agent_name": "My Custom Calculator Agent",
164+
"agent_description": "Provides advanced mathematical calculations for document analysis"
163165
},
164166
{
165167
"mcp_url": "https://your-second-mcp-server.example.com/mcp",
@@ -177,6 +179,8 @@ In the AWS account where the IDP solution is deployed, create a secret with your
177179
- `cognito_client_id`: The App Client ID from Step 2
178180
- `cognito_username`: The username created in Step 2
179181
- `cognito_password`: The permanent password set in Step 2
182+
- `agent_name` (optional): Custom name for the agent (defaults to "External MCP Agent {N}")
183+
- `agent_description` (optional): Custom description for the agent (tool information is automatically appended)
180184

181185
### Step 5: Verify Integration
182186

lib/idp_common_pkg/idp_common/agents/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ The agent requires credentials stored in AWS Secrets Manager at `{StackName}/ext
154154
"cognito_user_pool_id": "us-east-1_XXXXXXXXX",
155155
"cognito_client_id": "xxxxxxxxxxxxxxxxxxxxxxxxxx",
156156
"cognito_username": "<your first user here>",
157-
"cognito_password": "<your first password here>"
157+
"cognito_password": "<your first password here>",
158+
"agent_name": "My Custom Calculator Agent",
159+
"agent_description": "Provides advanced mathematical calculations"
158160
},
159161
{
160162
"mcp_url": "https://your-second-mcp-server.com/mcp",
@@ -166,6 +168,10 @@ The agent requires credentials stored in AWS Secrets Manager at `{StackName}/ext
166168
]
167169
```
168170

171+
**Optional Fields:**
172+
- `agent_name`: Custom name for the agent (defaults to "External MCP Agent {N}")
173+
- `agent_description`: Custom description (tool information is automatically appended)
174+
169175
**Usage:**
170176
```python
171177
from idp_common.agents.factory import agent_factory

lib/idp_common_pkg/idp_common/agents/factory/registry.py

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"""
1919

2020
import logging
21+
import uuid
2122

2223
from ..analytics.agent import create_analytics_agent
2324

@@ -128,15 +129,15 @@ def wrapper(config=None, session=None, model_id=None, **kwargs):
128129
test_strands_agent, test_mcp_client = test_result
129130

130131
# Extract available tools for dynamic description
131-
dynamic_description = f"Agent {i} which connects to external MCP servers to provide additional tools and capabilities"
132+
tools_description = ""
132133
if (
133134
hasattr(test_strands_agent, "tool_names")
134135
and test_strands_agent.tool_names
135136
):
136137
tool_names = list(test_strands_agent.tool_names)
137138
if tool_names:
138139
tools_list = ", ".join(tool_names)
139-
dynamic_description = f"Agent {i} with access to external MCP tools: {tools_list}. Use this agent to access external capabilities and services."
140+
tools_description = f" The tools available are: {tools_list}."
140141

141142
# Clean up the test MCP client
142143
if test_mcp_client:
@@ -148,21 +149,39 @@ def wrapper(config=None, session=None, model_id=None, **kwargs):
148149

149150
except Exception as e:
150151
logger.warning(f"Could not discover MCP tools for agent {i}: {e}")
151-
dynamic_description = f"Agent {i} which connects to external MCP servers to provide additional tools and capabilities"
152+
tools_description = ""
153+
154+
# Determine agent name and ID
155+
if "agent_name" in mcp_config and mcp_config["agent_name"]:
156+
agent_name = mcp_config["agent_name"]
157+
# Create ID from name with UUID for uniqueness
158+
name_no_spaces = agent_name.replace(" ", "_").lower()
159+
agent_id = f"{name_no_spaces}_{str(uuid.uuid4())[:8]}"
160+
else:
161+
agent_name = f"External MCP Agent {i}"
162+
agent_id = f"external-mcp-agent-{i}"
163+
164+
# Determine agent description
165+
if "agent_description" in mcp_config and mcp_config["agent_description"]:
166+
agent_description = mcp_config["agent_description"] + tools_description
167+
else:
168+
agent_description = f"Agent which connects to external MCP servers to provide additional tools and capabilities.{tools_description}"
152169

153170
# Register the agent
154171
agent_factory.register_agent(
155-
agent_id=f"external-mcp-agent-{i}",
156-
agent_name=f"External MCP Agent {i}",
157-
agent_description=dynamic_description,
172+
agent_id=agent_id,
173+
agent_name=agent_name,
174+
agent_description=agent_description,
158175
creator_func=create_mcp_agent_wrapper(),
159176
sample_queries=[
160177
"What tools are available from the external MCP server?",
161178
"Help me use the external tools to solve my problem",
162179
"Show me what capabilities the MCP server provides",
163180
],
164181
)
165-
logger.info(f"External MCP Agent {i} registered successfully")
182+
logger.info(
183+
f"External MCP Agent '{agent_name}' registered successfully with ID '{agent_id}'"
184+
)
166185

167186
except Exception as e:
168187
logger.warning(

0 commit comments

Comments
 (0)