|
| 1 | +# MCP Workflow Prompt Guidelines |
| 2 | + |
| 3 | +To ensure that LLMs and Clients can reliably parse and execute multi-step workflows in an efficient "headless" mode, all workflow prompts must adhere to the following structural and semantic guidelines. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## 1. Core Principles |
| 8 | + |
| 9 | +* **Clarity over cleverness**: The plan should be written as a simple, unambiguous set of instructions. Avoid complex prose or implicit steps. |
| 10 | + |
| 11 | +* **Structure is mandatory**: The parser relies on specific Markdown elements (headers, lists) and keywords to understand the plan's logic. |
| 12 | + |
| 13 | +* **One action per step**: Each bullet point should correspond to a single tool call. |
| 14 | + |
| 15 | +--- |
| 16 | + |
| 17 | +## 2. Structural Requirements |
| 18 | + |
| 19 | +### a. Overall Structure |
| 20 | + |
| 21 | +The prompt should be divided into logical **Phases** using Markdown H2 headers. Each phase represents a major stage of the workflow. |
| 22 | + |
| 23 | +* `# Name: [Prompt Name]` |
| 24 | + |
| 25 | +* `# Description: [High-level description of the prompt's purpose]` |
| 26 | + |
| 27 | +* `## Phase 1 - [Descriptive Name of Phase]` |
| 28 | + |
| 29 | +* `...` |
| 30 | + |
| 31 | +* `## Phase 2 - [Descriptive Name of Phase]` |
| 32 | + |
| 33 | +* `...` |
| 34 | + |
| 35 | +### b. Steps |
| 36 | + |
| 37 | +Within each phase, individual actions **must** be specified as bullet points (`-`). Each bullet point represents a single step in the sequence. |
| 38 | + |
| 39 | +#### Example: Phase 2 - Collect Table Information |
| 40 | + |
| 41 | +* **Step 1**: Get the table structure using the `base_tableDDL` tool. |
| 42 | + |
| 43 | +* **Step 2**: Gather column statistics using the `qlty_columnSummary` tool. |
| 44 | + |
| 45 | +### c. Loops |
| 46 | + |
| 47 | +Loops **must** be explicitly declared using one of the following keyword phrases: |
| 48 | + |
| 49 | +* `Cycle through the list of [items]...` |
| 50 | + |
| 51 | +* `For each [item] in the list...` |
| 52 | + |
| 53 | +The placeholder `[items]` (e.g., "tables", "columns") is crucial for the parser to understand what it is iterating over. The steps to be executed inside the loop should be defined in an indented list immediately following the loop declaration. |
| 54 | + |
| 55 | +#### Example: Phase 2 - Collect Table Information |
| 56 | + |
| 57 | +Cycle through the list of tables, for each table do the following steps in order: |
| 58 | + |
| 59 | +* **Step 1**: Get the table structure using the `base_tableDDL` tool. |
| 60 | + |
| 61 | +* **Step 2**: Gather column statistics using the `qlty_columnSummary` tool. |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## 3. Semantic Requirements |
| 66 | + |
| 67 | +### a. Explicit Tool Naming |
| 68 | + |
| 69 | +Every action step **must** explicitly name the tool to be used with the phrase `...using the [tool_name] tool`. The `[tool_name]` must match the exact name of a tool available on the MCP server. |
| 70 | + |
| 71 | +### b. Parameter Placeholders |
| 72 | + |
| 73 | +When a tool's argument should be filled in dynamically from the context of a loop, use the singular form of the loop item as a placeholder. The headless executor's **Authoritative Context Stack** will automatically substitute this at runtime. |
| 74 | + |
| 75 | +* If the loop is `For each table...`, the steps inside can refer to `table_name`. |
| 76 | + |
| 77 | +* If the loop is `For each column...`, the steps inside can refer to `column_name`. |
| 78 | + |
| 79 | +* **Do not** hardcode specific values inside a loop's definition. |
| 80 | + |
| 81 | +### c. Best Practices for Parameter Definition on MCP Server |
| 82 | + |
| 83 | +For effective and robust workflows, parameters should be clearly defined within the MCP environment, often resembling a YAML schema. Here's an example: |
| 84 | + |
| 85 | +```yaml |
| 86 | +# Example Parameter Definition for an MCP Tool |
| 87 | +tool_parameters: |
| 88 | + database_name: |
| 89 | + description: "The name of the database to connect to." |
| 90 | + type: "string" |
| 91 | + required: true |
| 92 | + default: "default_db" # Optional: provides a fallback if not specified |
| 93 | + table_name: |
| 94 | + description: "The name of the table to perform operations on." |
| 95 | + type: "string" |
| 96 | + required: false # Can be omitted if a default is provided or it's genuinely optional |
| 97 | + analysis_level: |
| 98 | + description: "A numeric value indicating the depth or intensity of the analysis (e.g., 1 for basic, 5 for comprehensive)." |
| 99 | + type: "integer" # Using an integer type |
| 100 | + required: true |
| 101 | + default: 3 |
| 102 | + output_format: |
| 103 | + description: "The desired format for the output data." |
| 104 | + type: "string" |
| 105 | + required: false |
| 106 | + default: "json" |
| 107 | +``` |
| 108 | +
|
| 109 | +In this structure: |
| 110 | +
|
| 111 | +* `description`: Provides a human-readable explanation of the parameter's purpose. |
| 112 | + |
| 113 | +* `type`: Specifies the data type expected for the parameter (e.g., `string`, `integer`, `boolean`, `enum`). |
| 114 | + |
| 115 | +* `required`: A boolean (`true`/`false`) indicating whether the parameter **must** be provided for the tool to execute. |
| 116 | + |
| 117 | +* `default`: An optional value that will be used if the parameter is not explicitly provided in the workflow step. |
| 118 | + |
| 119 | +--- |
| 120 | + |
| 121 | +## 4. Example: Complete Workflow Prompt |
| 122 | + |
| 123 | +Here is a complete example of a well-formed workflow prompt that adheres to all guidelines from Chapters 1, 2, and 3. This structure enables specialised clients to parse the entire plan once and then execute it deterministically, only calling the LLM if an error occurs. |
| 124 | + |
| 125 | +### Workflow Prompt Parameters |
| 126 | + |
| 127 | +These are the parameters that the workflow prompt itself accepts as input: |
| 128 | + |
| 129 | +```yaml |
| 130 | +workflow_parameters: |
| 131 | + db_name: |
| 132 | + description: "The name of the database to be audited." |
| 133 | + type: "string" |
| 134 | + required: true |
| 135 | +``` |
| 136 | + |
| 137 | +### Workflow Prompt |
| 138 | + |
| 139 | +```markdown |
| 140 | +# Name: Database Schema and Quality Audit |
| 141 | +# Description: |
| 142 | +You are a Teradata DBA performing a full schema and quality audit on a given database. |
| 143 | +
|
| 144 | +## Phase 1 - Get Database Objects |
| 145 | +- Get a list of tables in the {db_name} database using the `base_tableList` tool. |
| 146 | + |
| 147 | +## Phase 2 - Detailed Table Analysis |
| 148 | +Cycle through the list of tables, for each table do the following steps in order: |
| 149 | + - Step 1: Get the table's DDL using the `base_tableDDL` tool. |
| 150 | + - Step 2: Get a summary of all columns in the table using the `base_columnDescription` tool. |
| 151 | + - Step 3: Check for missing values in the table using the `qlty_missingValues` tool. |
| 152 | + |
| 153 | +## Phase 3 - Final Summary |
| 154 | +- You have now collected all the necessary data. Synthesize the results to provide a final report. |
0 commit comments