## Tool: `generate_query_from_schema`

Generates a GraphQL query based on a natural language prompt and a user-provided local GraphQL schema.

**When to use it:**

- Use this tool to generate GraphQL queries using a local GraphQL schema string without requiring a deployed service.

**How to use it:**

- Call `generate_query_from_schema` with `projectId`, `location`, `schema` (GraphQL SDL content string), and `prompt`.
- Use `list_locations` to find a valid location for `location` (any location works; choosing a closer region reduces latency).

**JSON Example:**

    {
              "projectId": "my-project",
              "location": "us-central1",
              "schema": "type Movie @table { title: String! genre: String }",
              "prompt": "List all movies in the Action genre"
            }
            

The following code sample shows how to use `curl` to call the `generate_query_from_schema` MCP tool.

| Curl Request |
|---|
| ```bash curl --location 'https://firebasedataconnect.googleapis.com/mcp' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "generate_query_from_schema", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' ``` |

## Input Schema

Request message for GenerateQueryFromSchema facade (local schema mode).

### GenerateQueryFromSchemaRequest

| JSON representation |
|---|
| ``` { "projectId": string, "location": string, "schema": string, "prompt": string } ``` |

| Fields ||
|---|---|
| `projectId` | `string` Required. The project ID or number. |
| `location` | `string` Required. The location of the service. |
| `schema` | `string` Required. The user-provided local GraphQL schema content string. |
| `prompt` | `string` Required. The natural language description of the desired query. |

## Output Schema

Output for streaming generate query requests

### GenerateQueryResponse

| JSON representation |
|---|
| ``` { // Union field `output_chunk` can be only one of the following: "status": { object (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.GenerationStatus`) }, "part": { object (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.Part`) } // End of list of possible types for union field `output_chunk`. } ``` |

| Fields ||
|---|---|
| Union field `output_chunk`. The streamed output chunk from the generation process. `output_chunk` can be only one of the following: ||
| `status` | ``object (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.GenerationStatus`)`` Essential for providing responsive UI feedback (e.g., a spinner or "Analyzing schema..." step). |
| `part` | ``object (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.Part`)`` Required. The content from the current conversational turn. |

### GenerationStatus

| JSON representation |
|---|
| ``` { "state": enum (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.State`), "message": string } ``` |

| Fields ||
|---|---|
| `state` | ``enum (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.State`)`` Output only. The state of generation. |
| `message` | `string` Output only. A message providing more details about the state. |

### Part

| JSON representation |
|---|
| ``` { // Union field `data` can be only one of the following: "textChunk": { object (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.TextChunk`) }, "codeChunk": { object (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.CodeChunk`) } // End of list of possible types for union field `data`. } ``` |

| Fields ||
|---|---|
| Union field `data`. The content from the current conversational turn. `data` can be only one of the following: ||
| `textChunk` | ``object (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.TextChunk`)`` Optional. A chunk of text. |
| `codeChunk` | ``object (`https://firebase.google.com/docs/reference/sql-connect/mcp/tools_list/generate_query#Output.Schema.CodeChunk`)`` Optional. A chunk of code. |

### TextChunk

| JSON representation |
|---|
| ``` { "text": string } ``` |

| Fields ||
|---|---|
| `text` | `string` Required. The text content string. |

### CodeChunk

| JSON representation |
|---|
| ``` { "code": string, "languageCode": string } ``` |

| Fields ||
|---|---|
| `code` | `string` Required. The code content string. |
| `languageCode` | `string` Optional. Specifies the language if we expand support beyond GraphQL (e.g., SQL or JSON) The standard is BCP-47 language code. |

### State

Represents the state of generation.

| Enums ||
|---|---|
| `STATE_UNSPECIFIED` | Unspecified state. |
| `ANALYZING_CODE` | The agent is analyzing schema or operations. |
| `GENERATING_CODE` | The agent is generating code |
| `COMPLETED` | Generation is complete. |

### Tool Annotations


[Tool annotations](https://modelcontextprotocol.io/specification/latest/schema#toolannotations) are sent to MCP clients to describe the basic risk of a given tool. Most clients treat these hints as untrusted, but they can be used to decide when a confirmation prompt might be sent to a user.


Along with the title string, the following boolean hints are defined as follows:

- `readOnlyHint`: If true, the tool doesn't modify its environment. Default: false.
- `destructiveHint`: If true, then the tool can perform destructive actions. If false, then the tool can only perform additive actions. Default: true.
- `idempotentHint`: If true, then calling the tool repeatedly with the same arguments will have no additional effect on its environment. Default: false.
- `openWorldHint`: If true, then the tool can interact with an 'open world' of external entities. If false, then the tool can only interact with internal entities. For example, a web search tool would be open world, while a memory tool would not be open world.

Destructive Hint: ❌ \| Idempotent Hint: ❌ \| Read Only Hint: ✅ \| Open World Hint: ❌