# MCP server configuration

> Declare an MCP server configuration that exposes a project's authorization decisions and Knowledge Queries to Model Context Protocol clients, with the indykite_mcp_server resource.

**Category:** MCP
**Tags:** MCP, Model Context Protocol, AI Agents, Token Introspect
**Last Updated:** 2026-10-12
**Terraform Provider Docs:** https://registry.terraform.io/providers/indykite/indykite/latest/docs/resources/mcp_server
**Related Guides:** /guides/guide-mcp, /guides/guide-token-introspect, /guides/guide-terraform

## Summary

An MCP server configuration is what lets an AI agent call IndyKite over the Model Context Protocol: it names the Application Agent the server acts as, the Token Introspect configuration that validates the end-user tokens it receives, and the OAuth scopes it advertises.
This Terraform configuration creates one MCP server that:
1. Acts as the Application Agent in app_agent_id, which needs the Authorization and ContXIQ permissions for the AuthZEN and ContX IQ tools.
2. Validates callers with the Token Introspect configuration in token_introspect_id.
3. Advertises the read scope and is enabled.
The agent and the Token Introspect configuration must exist in the same project; when they are managed in the same module, reference their resource attributes instead of pasting GIDs.

## Use Case

Scenario: a support assistant built on an LLM must make authorization decisions and read graph data on behalf of the signed-in user.
- The MCP server is declared next to the agent and the Token Introspect configuration it depends on, in one reviewed module.
- The assistant's MCP client connects with the user's token and the server's tools (authzen_evaluate, ciq_execute and the others) run under that user's identity.
- Setting enabled to false takes the server offline without deleting its configuration, for example while the agent's credentials are rotated.

## Requirements

- ServiceAccount credentials created in the IndyKite Hub for your organization.
- IndyKite Terraform provider 0.49.0 or later, the release the example pins in required_providers; the Terraform guide lists the version each feature first appeared in.
- A project GID, an Application Agent with the Authorization and ContXIQ permissions, and a Token Introspect configuration for the identity provider issuing the users' tokens, all in that project.

## Steps

1. Put your project, agent and Token Introspect GIDs in the three identifier arguments, or reference the resources that create them.
2. Choose the scopes to advertise and apply.
3. Point an MCP client at the project's MCP endpoint with a user token, as the MCP guide shows, and list the tools.
4. Set enabled to false and apply to take the server offline; set it back to true to restore it.

## Code Examples


An enabled MCP server bound to an Application Agent and a Token Introspect configuration.

**main.tf**

```hcl

terraform {
  required_providers {
    indykite = {
      source  = "indykite/indykite"
      version = ">= 0.49.0" # or a later release
    }
  }
}

# indykite provider integrates IndyKite platform with Terraform scripting.
# Provider for now does not support any parameters and all is set within service account credential file.
provider "indykite" {}

# An MCP server configuration exposes a project's authorization decisions and
# Knowledge Queries to Model Context Protocol clients. It calls IndyKite as the
# Application Agent in app_agent_id (grant it the Authorization and ContXIQ
# permissions) and validates the end-user tokens it receives with the Token
# Introspect configuration in token_introspect_id. Both must exist in the same
# project; reference the resources when they are managed in the same module.
resource "indykite_mcp_server" "assistant" {
  name                = "terraform-mcp-server"
  display_name        = "Terraform MCP server"
  description         = "Graph access for the support assistant"
  project_id          = "gid:AAAAAmluZHlraURlgAABDwAAAAA"  # your project GID
  app_agent_id        = "gid:AAAABWluZHlraURlgAAFDwAAAAA"  # your Application Agent GID, or indykite_application_agent.<name>.id
  token_introspect_id = "gid:AAAABnRva2VuSW50cm9zcGVjdAAA" # your Token Introspect GID, or indykite_token_introspect.<name>.id
  scopes_supported    = ["read"]                           # the OAuth scopes the server advertises; at least one
  enabled             = true                               # false keeps the configuration; MCP requests are answered 403
}

```

## Common Errors

### INVALID_ARGUMENT: invalid input values

**Solution:** app_agent_id and token_introspect_id must be GIDs of objects in the same project as project_id; the platform refuses a GID of another project or of a deleted object.

### ALREADY_EXISTS: mcp server already exists in project

**Solution:** A project has at most one MCP server configuration. Update the existing one, or import it into Terraform state.

---

Source: https://developer.indykite.com/terraform/terraform-13