MCP Tools
Map GraphQL operations to MCP tools in Hive Gateway. Tool sources, directives, input and output shaping, hooks and annotations.
A tool is one GraphQL operation exposed to agents under a name of your choice. The plugin derives the tool’s input schema from the operation’s variables and its output schema from the selection set, so agents know what to send and what to expect. This page walks through every part of a tool definition.
A complete tool definition
Only name and source are required; everything else refines how the tool is presented and
executed.
Tool sources
The source tells the plugin where the GraphQL operation comes from.
Inline queries
The operation is written directly in the configuration:
Named operations from files
Point the plugin at a .graphql file, or a directory of them, with operationsPath, then reference
operations by name:
A tool can load its operation from a specific file instead of the global operationsPath with
source.file:
operationsStr accepts the operations as a string instead of a file path, and the
dynamic loader fetches them from anywhere
for each MCP request.
Directives in operation files
Operations can declare themselves as tools with the @mcpTool directive, which removes the need for
a tools entry:
@mcpTool also accepts descriptionProvider (see
Description providers) and meta, an object passed
through to clients as the tool’s _meta:
When the same tool is both declared with a directive and listed in tools, the configuration
entry’s values win; meta objects are shallow-merged with the configuration taking precedence on
conflicting keys.
Input schema
Aliases, descriptions, examples and defaults
Override how each variable appears to agents under input.schema.properties, keyed by the GraphQL
variable name:
Agents see a city parameter with the description, examples and default; the plugin maps it back to
location when it executes the query.
Field descriptions from directives
@mcpDescription attaches a description to a variable or a selected field, either inline or via a
description provider:
Values from HTTP headers
Some variables should never come from the agent, such as a tenant or user id that your
authentication layer puts in a header. @mcpHeader hides the variable from the input schema and
fills it from the named request header on every call:
If the header is missing, the tool call returns an error. When you need more control, for example to
transform the header value or fall back to a default, hide the variable with hidden: true and set
it in a preprocess hook:
Output
Extract part of the response
By default a tool returns the whole data object of the GraphQL response. output.path narrows it
to a nested value, and the output schema advertised in tools/list is narrowed to match:
Without path, the agent receives { cities: [{ name: "London", ... }] }; with path: "cities" it
receives the array directly.
Output schema and annotations
output.schema: falseomits the output schema for one tool.suppressOutputSchema: trueon the plugin does it for all tools. Output schemas are also omitted automatically when a tool has hooks, because hooks may change the shape of the result.output.contentAnnotationsattaches MCP content annotations (audience,priority,lastModified) to the returned content items.output.descriptionProvidersadds dynamic descriptions to output fields, keyed by dot-notation path:
Hooks
Hooks let you intercept a tool call before and after the GraphQL execution. Both receive a context
with toolName, the request headers sent by the agent, and the resolved GraphQL query.
Preprocess
preprocess runs before execution with the de-aliased arguments (original variable names). Return
undefined to continue, or return any value to short-circuit and use it as the tool result:
When preprocess short-circuits, postprocess is not called.
Postprocess
postprocess receives the GraphQL result (after output.path extraction), the arguments and the
context, and returns what the agent gets:
A string result is sent as text content instead of structured content.
Annotations and task support
tool.annotations gives clients behavioral hints, following the MCP specification:
| Hint | Meaning |
|---|---|
readOnlyHint | The tool does not modify its environment. Clients assume false. |
destructiveHint | The tool may perform destructive updates. Clients assume true. |
idempotentHint | Repeated calls with the same arguments have no extra effect. |
openWorldHint | The tool interacts with external entities beyond a closed domain. |
tool.execution.taskSupport declares whether a tool supports task-augmented execution for
long-running operations: "forbidden" (default), "optional" or "required".
Other presentation options on tool are title, icons (a list of
{ src, mimeType, sizes, theme } objects for client UIs) and _meta for opaque metadata.