Skip to content

Commit 69f6c96

Browse files
feat(mcp): Add test-my-tools prompt with optional scope parameter (#893)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent 9301599 commit 69f6c96

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

airbyte/mcp/prompts.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# Copyright (c) 2024 Airbyte, Inc., all rights reserved.
2+
"""MCP prompt definitions for the PyAirbyte MCP server.
3+
4+
This module defines prompts that can be invoked by MCP clients to perform
5+
common workflows.
6+
"""
7+
8+
from __future__ import annotations
9+
10+
from typing import TYPE_CHECKING, Annotated
11+
12+
from pydantic import Field
13+
14+
15+
if TYPE_CHECKING:
16+
from fastmcp import FastMCP
17+
18+
19+
TEST_MY_TOOLS_GUIDANCE = """
20+
Test all available tools in this MCP server to confirm they are working properly.
21+
22+
Guidelines:
23+
- Iterate through each tool systematically
24+
- Use read-only operations whenever possible
25+
- For tools that modify data, use test/safe modes or skip if no safe testing method exists
26+
- Avoid creating persistent side effects (e.g., don't create real resources, connections, or data)
27+
- Document which tools were tested and their status
28+
- Report any errors or issues encountered
29+
- Provide a summary of the test results at the end
30+
31+
Focus on validating that tools:
32+
1. Accept their required parameters correctly
33+
2. Return expected output formats
34+
3. Handle errors gracefully
35+
4. Connect to required services (if applicable)
36+
37+
Be efficient and practical in your testing approach.
38+
""".strip()
39+
40+
41+
def test_my_tools_prompt(
42+
scope: Annotated[
43+
str | None,
44+
Field(
45+
description=(
46+
"Optional free-form text to focus or constrain testing. "
47+
"This can be a single word, a sentence, or a paragraph "
48+
"describing the desired scope or constraints."
49+
),
50+
),
51+
] = None,
52+
) -> list[dict[str, str]]:
53+
"""Generate a prompt that instructs the agent to test available tools."""
54+
content = TEST_MY_TOOLS_GUIDANCE
55+
56+
if scope:
57+
content = f"{content}\n\n---\n\nAdditional scope or constraints:\n{scope}"
58+
59+
return [
60+
{
61+
"role": "user",
62+
"content": content,
63+
}
64+
]
65+
66+
67+
def register_prompts(app: FastMCP) -> None:
68+
"""Register all prompts with the FastMCP app."""
69+
app.prompt(
70+
name="test-my-tools",
71+
description="Test all available MCP tools to confirm they are working properly",
72+
)(test_my_tools_prompt)

airbyte/mcp/server.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from airbyte.mcp.cloud_ops import register_cloud_ops_tools
1212
from airbyte.mcp.connector_registry import register_connector_registry_tools
1313
from airbyte.mcp.local_ops import register_local_ops_tools
14+
from airbyte.mcp.prompts import register_prompts
1415

1516

1617
set_mcp_mode()
@@ -22,6 +23,7 @@
2223
register_connector_registry_tools(app)
2324
register_local_ops_tools(app)
2425
register_cloud_ops_tools(app)
26+
register_prompts(app)
2527

2628

2729
def main() -> None:

0 commit comments

Comments
 (0)