LLM Prompt Injection Strategy via Info Tools
Relevant source files
The following files were used as context for generating this wiki page:
The Stacklet MCP server implements a structured context-loading strategy that provides Large Language Models (LLMs) with essential technical guidance, schema definitions, and best practices through specialized "Info Tools." These tools act as a primary interface for injecting necessary domain-specific knowledge into the LLM's prompt context, ensuring accurate tool usage and reduced hallucination when interacting with cloud governance data.
This strategy centralizes critical metadata—such as SQL schema details, GraphQL connection patterns, and data scale warnings—into dedicated endpoints that the server instructs the agent to call before performing data operations. This ensures the LLM understands the limitations and requirements of the multi-cloud estate, including AWS, GCP, Azure, and Tencent environments.
Sources: stacklet/mcp/mcp_info.md:1-12, README.md:9-12, CLAUDE.md:14-25
Info Tool Architecture and Flow
The server exposes one primary info tool for each major component (AssetDB, Platform GraphQL, and Documentation). The system relies on the LLM recognizing the "critical" priority of these tools to initialize its internal state with Stacklet-specific logic.
The diagram shows the recommended workflow where the Agent populates its prompt context using Info Tools before executing functional data operations.
Sources: stacklet/mcp/mcp_info.md:5-10, stacklet/mcp/assetdb/tools.py:73-82
Critical Info Tools
The following table summarizes the primary tools used to inject system-specific instructions into the LLM context:
| Tool Name | Scope | Primary Injected Information |
|---|---|---|
assetdb_sql_info | Asset Analysis | PostgreSQL 16 schema, scale warnings, and indexing requirements. |
platform_graphql_info | Governance | GraphQL query patterns, connection best practices, and "problems" field requirements. |
platform_dataset_info | Data Export | JMESPath examples, FilterElementInput structures, and export timeouts. |
docs_list | Documentation | Inventory of available live documentation files. |
Sources: stacklet/mcp/mcp_info.md:5-10, CLAUDE.md:104-120
AssetDB Context Injection (SQL)
The assetdb_sql_info tool injects a comprehensive guide for the PostgreSQL 16 warehouse. This information prevents the LLM from executing dangerous table scans on "Very Large" tables like resources and resource_revisions.
Schema and Performance Guidance
- Scale Warnings: The tool explicitly labels table sizes (e.g.,
resource_revisionsas "Extremely Large") to force the use ofLIMITand indexed filters. - Table Bridge Mapping: It provides mapping for lookup tables like
account_idandresource_idto link cost tables with provider details. - SQL Injection Awareness: It notifies the LLM that
textparameters use template substitution rather than prepared statements, requiring the agent to prefer validated types likenumberordate.
Sources: stacklet/mcp/assetdb/sql_info.md:1-55, stacklet/mcp/assetdb/tools.py:73-82
Platform GraphQL Context Injection
The platform_graphql_info tool directs the LLM to follow specific interaction patterns required by the Stacklet Platform API.
Connection Best Practices
The injected context mandates specific behaviors to prevent API timeouts and context overflow:
- Small Page Sizes: Instructions to use pages of 5-10 items.
- Mandatory "Problems" Field: Every query must include the
problemsfield to capture critical execution metadata. - Schema Discovery: The LLM is instructed to query
filterSchemabefore attempting to build complexFilterElementInputobjects.
This sequence illustrates how the info tool injection leads to the correct query structure (inclusion of problems and pagination).
Sources: stacklet/mcp/platform/graphql_info.md:1-25, stacklet/mcp/platform/dataset_info.md:1-25
Prompt Injection via Documentation
The documentation tools (docs_list and docs_read) provide the LLM with live knowledge regarding Cloud Governance and Sinistral (IaC Governance).
- Sinistral vs. Custodian: The injected info clarifies that Sinistral policies are YAML evaluated against Terraform, while Cloud Custodian policies are evaluated against live resources.
- LLM-Optimized Docs: The server fetches documentation specifically designed for AI assistance, which is available under the
iac/andreference/paths. - Error Recovery: If a requested document path is missing, the tool injects a message instructing the agent to call
docs_listto see valid paths rather than hallucinating content.
Sources: stacklet/mcp/mcp_info.md:31-45, tests/test_tools_docs.py:77-96
Summary of Strategy Significance
The Info Tool strategy ensures that the LLM is not operating in a vacuum when interacting with complex cloud data. By prioritizing these tools, the system:
- Protects Performance: Prevents massive SQL scans by injecting index and limit awareness.
- Ensures Accuracy: Provides the exact JMESPath and GraphQL patterns required for Stacklet's specific API implementation.
- Maintains Security: Informs the LLM of data sensitivity and the risks of template-based SQL parameter substitution.
Developers should ensure that any new server modules include a corresponding *_info tool to maintain this architectural pattern.
Sources: stacklet/mcp/mcp_info.md:1-10, README.md:14-20, CLAUDE.md:104-120