---
name: next-config
description: >
  Inspect and configure NEXT tagging agents and workflows. Use when the user
  wants to manage AI or search tagging of memories, inspect tags, or create,
  validate, update, or test NEXT workflows.
---

# NEXT Configuration

Use the installed NEXT MCP tools to inspect and configure tagging agents and
workflows in the NEXT scope authorized by the user's token. MCP tool
discovery provides the authoritative current tool descriptions and schemas;
inspect it instead of relying on remembered parameter details.

## Route requests to the right tools

- Use memory tools such as `search-memories` to inspect memory content and
  understand what a proposed tagging agent would process. These are separate
  from configuration tools.
- Use `list_tagging_agents` to inspect existing AI and search tagging agent
  configurations. It supports type, text search, and pagination filters.
- Use `list_tags` to inspect tags, optionally filtering by group or text.
- Use workflow tools to discover, inspect, validate, create, update, and test
  workflows. Do not expose the underlying server split unless it helps
  diagnose a tool or connection problem.

## Tagging agents

Choose AI tagging when classification needs semantic judgment, such as issue
type, customer need, churn reason, sentiment, or product area. Choose search
tagging when a deterministic expression accurately describes the rule.

Before designing an agent, inspect existing agents and relevant tags. Search
memory content when examples are needed to define useful boundaries. Reuse
existing names, tag groups, and tags where appropriate; avoid duplicate or
overlapping configurations.

For an AI agent, give every tag a clear description that explains when it
should be applied, usually starting with `Use for:`. For a search agent, use
case-insensitive expressions. Commas mean alternatives; `field:value` filters
are supported for `evidence_text`, `title`, `description`, `contributor.name`,
`contributor_title`, `contact`, and `recording.account`. Quote values with
spaces. `*` is supported only by itself to match every memory; embedded `*`
and `?` are unsupported.

`limit_tag_ids` optionally restricts which memories an agent evaluates. Omit
it or pass an empty array for no restriction. Confirm any supplied IDs with
`list_tags`.

Always call `validate_ai_tagging_agent` or
`validate_search_tagging_agent` before creation. Fix validation errors before
calling `create_ai_tagging_agent` or `create_search_tagging_agent`. Creation
validates again, reuses tags with the same normalized name and group, creates
missing tags, and creates an active agent. Validation may warn when a reused
AI tag has a different description; surface that difference before proceeding
when it could affect classification. Validation also checks agent-name
uniqueness across both agent types, duplicate input tags, missing scope tag
IDs, and same-name tags in other groups.

## Workflows

Use `list_workflow_step_definitions` before designing a workflow. It returns
the live step types, parameter and output schemas, required integrations,
branch handles, test behavior, and built-in variables. Use `list_workflows` or
`get_workflow` to inspect existing workflows and conventions. The workflow
representation omits editor positions, annotations, pinned test outputs, and
internal connection IDs.

Build a complete workflow definition with step IDs used as connection aliases,
variable-safe unique slugs, and connections between those IDs. Use
`{{slug.output}}` to reference an upstream step. Include branch handles when a
step has multiple outputs. Call `validate_workflow` and resolve all errors
before writing. Validation checks step types and parameters, trigger and
connection structure, cycles, branch handles, reachability, and variable
references against built-in values and upstream output schemas.

Call `create_workflow` with the validated definition. Workflows default to
`paused`; request `active` only when the user wants immediate activation. The
server creates persistent step IDs, derives trigger metadata, generates the
editor layout, and returns a workflow ID and app link.

For updates, start with the complete definition from `get_workflow`, preserve
the workflow ID and IDs of existing steps (including renamed or changed
steps), then validate the full replacement definition. Call
`update_workflow` with `workflow_id` and an explicit `status`. The server
preserves valid existing step IDs, assigns IDs to new steps, and replaces the
workflow's steps and connections as one unit. Do not send a partial patch.

## Test workflows

Creating or updating a workflow does not authorize running it. Use this test loop only when the user asks to test the workflow or explicitly approves a proposed test run:

1. Call `prepare_workflow_test_data` with the workflow ID. For a partial run,
   set `target_step_id` to the downstream step where execution should stop;
   omit it to plan the full workflow. Never use the trigger as the target.
2. Inspect the planned steps before running anything. Build `mock_outputs`
   keyed by persisted step ID and shaped by each step's `output_schema`.
   Supply outputs for every `steps_requiring_mock` step. Supply mocks for
   optional-mock steps whose real execution should be avoided.
3. Steps listed in `steps_that_execute` always run. Optional-mock steps run
   normally when no mock is supplied. If any planned step could cause external
   side effects, explain which steps would execute and get the user's explicit
   approval before calling `test_workflow`. If the user does not approve, do
   not run those steps; propose a safer target or mock plan when possible.
4. After approval, call `test_workflow` with the same target and the approved
   mocks. Poll `get_workflow_test_result` using the returned execution ID.
   Use the result to refine the workflow, validate again, and repeat only with
   the user's authorization for another run.

The test plan distinguishes required mocks, optional mocks, and steps that
always execute. Optional-mock steps execute normally when no mock is supplied;
execute-only steps always run. Cron triggers have no payload and need no mock.
Pins are stored in the test execution's private workflow snapshot and do not
change the saved workflow.

Each test execution has a five-minute window. For large workflows, it can help
to mock outputs for steps that do not need to run. Alternatively, continue from
a previous successful test: run to a downstream target, then pass that
successful execution ID as `base_execution_id` to the next prepare and test
calls. Only successful upstream steps copied into the new execution are
reused; the selected target runs again and may still require a mock. Each
segment gets its own five-minute window.

## Authorization and scope

Configuration access is scoped by the NEXT token supplied to the MCP server.
Do not ask for or pass a `project_id` unless a tool's current schema
specifically requires one. Respect the scope authorized by the token and the
requested change scope. If the user asks only to inspect, design, or evaluate,
do not create or change configuration. A request to create or update
authorizes only that requested change; it does not authorize a test run.
