Repository avatar
AI Tools
v0.2.1
active

formkiq-mcp-server

io.github.formkiq/formkiq-mcp-server

Authenticated document search and retrieval for FormKiQ, read-only by default.

Documentation

FormKiQ MCP Server

MCP server for FormKiQ, exposing the FormKiQ OpenAPI spec and selected FormKiQ API operations as Model Context Protocol tools.

This server:

  • exposes the FormKiQ JWT OpenAPI spec as an MCP resource at openapi://formkiq/jwt
  • parses operation metadata from the OpenAPI document
  • proxies a curated set of FormKiQ operations as MCP tools
  • forwards calls to a deployed FormKiQ API using a JWT
  • defaults to read-only access, with separate opt-in write and purge tools
  • validates arguments and streams responses within a configurable size limit

Each MCP server release bundles an OpenAPI snapshot for offline startup. Its upstream source and checksum are recorded in provenance.json. The MCP server version and the upstream FormKiQ API version are independent.

Quick Start

For release installations, let your MCP client start this server with pipx from a GitHub release tag, using @vMAJOR.MINOR.PATCH.

These installation examples use MCP server release v0.2.1, available on GitHub and PyPI. For local development, use the checkout-based Install and Local Codex Development Setup instructions. Published releases are listed in Releases.

Use the FormKiQ CloudFormation HttpApiUrl output for JWT/Cognito authentication:

aws cloudformation describe-stacks \
  --stack-name "<formkiq-stack-name>" \
  --query "Stacks[0].Outputs[?OutputKey=='HttpApiUrl'].OutputValue | [0]" \
  --output text

Replace the example endpoint and JWT values below. Keep the same release tag across client configurations. The tag selects the application version; the checked-in uv.lock pins dependencies for checkout-based installations.

Codex Setup

Add this to ~/.codex/config.toml or to a trusted project's .codex/config.toml:

[mcp_servers.formkiq]
command = "pipx"
args = ["run", "--spec", "git+https://github.com/formkiq/formkiq-mcp-server.git@v0.2.1", "formkiq-mcp-server"]
env = { "MCP_TRANSPORT" = "stdio", "FORMKIQ_API_ENDPOINT_URL" = "https://abc123.execute-api.us-east-1.amazonaws.com", "FORMKIQ_JWT" = "eyJ..." }
startup_timeout_sec = 30
tool_timeout_sec = 60
enabled = true

Start a new Codex session and check:

/mcp

Claude Code Setup

Add the server from the CLI:

claude mcp add --transport stdio formkiq \
  --env FORMKIQ_API_ENDPOINT_URL=https://abc123.execute-api.us-east-1.amazonaws.com \
  --env FORMKIQ_JWT=eyJ... \
  --env MCP_TRANSPORT=stdio \
  -- pipx run --spec "git+https://github.com/formkiq/formkiq-mcp-server.git@v0.2.1" formkiq-mcp-server

Then check:

claude mcp list

Inside Claude Code, use:

/mcp

PyPI and the official MCP Registry

Release 0.2.1 is available on PyPI and in the official MCP Registry. It is also listed in the Glama MCP directory.

uvx --from formkiq-mcp-server==0.2.1 formkiq-mcp-server

For a client that starts the server over stdio, use command uvx, arguments ["--from", "formkiq-mcp-server==0.2.1", "formkiq-mcp-server"], and the same environment configuration shown above. Keep MCP_TRANSPORT=stdio, provide your deployment's HTTPS JWT endpoint and a current access token, and begin with the default read-only access. This package does not provision a shared public MCP endpoint.

server.json contains the official-registry metadata and marks the access token as a secret configuration value. Its name must match the mcp-name marker in the PyPI README. Do not add real endpoints, JWTs, caller tokens, or customer data to the manifest.

The Publish Python package and MCP Registry workflow publishes only from the tag matching the package and registry versions. Before the first publication, a PyPI owner must configure a trusted publisher for project formkiq-mcp-server, GitHub owner formkiq, repository formkiq-mcp-server, workflow publish.yml, and environment pypi. This publisher setup grants package-upload authority to that workflow and requires the account owner's approval. Publish the matching GitHub release only after CI passes.

After PyPI confirms the version is available, publish server.json using an identity authorized for io.github.formkiq/. Organization namespaces currently require GitHub Actions OIDC (mcp-publisher login github-oidc) or an organization Owner's token with organization-membership read access. Interactive device login cannot currently verify organization ownership. Follow the official authentication guide and GitHub Actions publishing guide; the release workflow uses the supported OIDC route after PyPI publication. Its registry job runs in the mcp-registry environment, verifies the pinned publisher with Sigstore, and checks that the PyPI README contains the ownership marker before publishing. Configure any required environment approval rules before releasing.

For a manual retry from an authorized environment, run mcp-publisher publish from the directory containing server.json. Prefer OIDC in the reviewed release workflow over creating a long-lived token.

The release workflow publishes the PyPI package and then its official-registry entry. Verify both listings after each publication. glama.json identifies the GitHub maintainers who can manage the Glama listing after connecting their GitHub accounts.

Requirements

  • Python 3.11+
  • Git for cloning the repository
  • pipx for GitHub-backed MCP client setup, or uv for local development
  • a deployed FormKiQ API endpoint URL from the FormKiQ CloudFormation outputs
  • a FormKiQ JWT for API calls

Install uv

macOS — with Homebrew:

brew install uv

Windows — in PowerShell, with WinGet:

winget install --id=astral-sh.uv -e

Linux — with the official standalone installer:

curl -LsSf https://astral.sh/uv/install.sh | sh

Open a new terminal after installation so PATH changes take effect, then verify:

uv --version

If uv is still not found, follow the installer's PATH instructions. See the official uv installation guide for alternatives, including the Windows standalone installer and the macOS installer without Homebrew.

Optional: Install pipx

The local checkout workflow below uses uv. If you use the release-based MCP client examples, install pipx after uv on any of these operating systems:

uv tool install pipx
pipx --version

See uv's tool installation guide if the pipx executable needs to be added to PATH.

Install

Run these commands in Terminal on macOS/Linux or PowerShell on Windows:

git clone https://github.com/formkiq/formkiq-mcp-server.git
cd formkiq-mcp-server
uv sync --locked

You can also run release v0.2.1 directly from GitHub with pipx:

pipx run --spec "git+https://github.com/formkiq/formkiq-mcp-server.git@v0.2.1" formkiq-mcp-server

Configure

Set the FormKiQ API endpoint and a current Cognito AccessToken from the same deployment. Set FORMKIQ_JWT to the token text; the server adds the Bearer prefix. Restart the server after changing the token. For JWT authentication, FORMKIQ_API_ENDPOINT_URL should be the HttpApiUrl value from the FormKiQ CloudFormation stack outputs.

For local development, copy the provided template without overwriting an existing file.

macOS/Linux:

cp -n .env.example .env

Windows PowerShell:

if (!(Test-Path .env)) { Copy-Item .env.example .env }

Edit .env with your deployment values:

FORMKIQ_API_ENDPOINT_URL=https://abc123.execute-api.us-east-1.amazonaws.com
FORMKIQ_JWT=your-raw-Cognito-AccessToken
MCP_TRANSPORT=streamable-http
FORMKIQ_API_GROUPS=core

Then start the server normally:

uv run --locked python server.py

Both python server.py and the installed formkiq-mcp-server entry point automatically load .env from the current working directory at startup. The server does not search parent directories. Existing environment variables, including empty values, take precedence over the file. If you previously exported an endpoint or JWT and want to use the file instead, clear those exports first:

unset FORMKIQ_API_ENDPOINT_URL FORMKIQ_API_BASE_URL FORMKIQ_JWT

In Windows PowerShell:

Remove-Item Env:FORMKIQ_API_ENDPOINT_URL, Env:FORMKIQ_API_BASE_URL, Env:FORMKIQ_JWT -ErrorAction SilentlyContinue

The template includes API Groups, module declarations, transport, and write/purge flags. File values are literal; ${VAR} interpolation is disabled. .env and .env.* files are ignored by Git, with .env.example included as the shareable template. Restart after editing the file; JWT refresh is still manual.

If your MCP client launches the server from a different directory, configure its working directory or use an explicit file path with uv:

uv run --locked --env-file /absolute/path/to/.env python server.py

uv reads the explicitly selected file before starting Python. Operators can set PYTHON_DOTENV_DISABLED=1 to disable the server's automatic .env loading. No file is required when configuration is supplied by the host or MCP client.

Alternatively, export settings directly:

export FORMKIQ_API_ENDPOINT_URL="https://abc123.execute-api.us-east-1.amazonaws.com"
export FORMKIQ_JWT="<raw-Cognito-AccessToken>"

Windows PowerShell equivalent:

$env:FORMKIQ_API_ENDPOINT_URL = "https://abc123.execute-api.us-east-1.amazonaws.com"
$env:FORMKIQ_JWT = "<raw-Cognito-AccessToken>"

FormKiQ exposes different API endpoint outputs for different authentication modes:

Authentication modeCloudFormation outputOpenAPI spec
JWT / CognitoHttpApiUrlopenapi-jwt.yaml
IAMIamApiUrlopenapi-iam.yaml
API KeyKeyApiUrlopenapi-key.yaml

This MCP server currently sends bearer JWTs through FORMKIQ_JWT. The neutral FORMKIQ_API_ENDPOINT_URL name is used so IAM and API key support can be added without renaming the endpoint variable again.

You can retrieve the JWT endpoint, HttpApiUrl, with the AWS CLI:

aws cloudformation describe-stacks \
  --stack-name "<formkiq-stack-name>" \
  --query "Stacks[0].Outputs[?OutputKey=='HttpApiUrl'].OutputValue | [0]" \
  --output text

Then export it directly:

export FORMKIQ_API_ENDPOINT_URL="$(aws cloudformation describe-stacks \
  --stack-name "<formkiq-stack-name>" \
  --query "Stacks[0].Outputs[?OutputKey=='HttpApiUrl'].OutputValue | [0]" \
  --output text)"

Changing the endpoint or OpenAPI document alone does not enable IAM signing or API-key authentication. This implementation supports JWT authentication only.

FORMKIQ_API_BASE_URL is still accepted as a deprecated alias for compatibility, but new configs should use FORMKIQ_API_ENDPOINT_URL.

Optional: override the bundled OpenAPI document with a compatible local file:

export FORMKIQ_OPENAPI_FILE="/path/to/formkiq-core/docs/openapi/openapi-jwt.yaml"

Optional: override the bundled document with an HTTPS URL (pin the URL to an immutable version). Set only one OpenAPI override:

export FORMKIQ_OPENAPI_URL="https://example.com/openapi-jwt.yaml"

Run Locally Over HTTP

uv run --locked python server.py

Or, after installing/running through pipx:

pipx run --spec "git+https://github.com/formkiq/formkiq-mcp-server.git@v0.2.1" formkiq-mcp-server

By default, the Python MCP SDK serves Streamable HTTP at:

http://localhost:8000/mcp

Use this mode for MCP clients that connect to an already-running HTTP server.

Run Over Stdio

Most local AI clients start MCP servers as child processes over stdio. This server supports that mode with:

MCP_TRANSPORT=stdio uv run --locked python server.py

You normally do not run that command manually. Instead, put it in your MCP client configuration.

Tools

Every enabled endpoint has a dedicated MCP tool generated from the pinned OpenAPI spec. Each tool exposes its path/query/header parameters and JSON request body schema, including required fields, types, enums, and referenced definitions. Tool names follow the operation ID in snake case (for example, GetDocumentOcr becomes get_document_ocr); DocumentSearch retains the established name search_documents.

The default core configuration exposes 29 tools: 25 endpoint tools plus four supporting tools:

  • list_formkiq_operations lists enabled endpoints, API groups, permissions, and toolName.
  • describe_operation provides focused schemas and examples for an operation ID.
  • call_formkiq_operation retains the generic read/search interface.
  • count_documents adds explicit count truncation/exactness information.

API Groups, installed modules, write/purge flags, and the current caller's operation allowlist filter both endpoint discovery and invocation. With all groups and required modules, read-only access exposes 40 endpoint tools plus the four supporting tools. Enabling writes and purge exposes up to 69 endpoint tools, with an additional generic write tool. The table below maps all supported endpoints to their tools.

Dedicated tools accept API parameter names directly. For example, call get_document with:

{"documentId":"abc-123","siteId":"default"}

Or call get_folder_documents with:

{"path":"invoices/2026","siteId":"default","limit":"10"}

JSON request bodies go in body, for example add_document_tags (with writes enabled):

{"documentId":"abc-123","siteId":"default","body":{"tags":[{"key":"type","value":"invoice"}]}}

Parameters keep the API's types (limit is usually a string). If a custom spec uses the same parameter name in multiple locations, tools expose location-prefixed names such as path_id and query_id; an API parameter named body also receives a location prefix. Unexpected fields are rejected before any backend request.

Supported FormKiQ API Endpoints

MethodPathOperation IDToolAPI groupAccess
GET/activitiesGetResourceActivitiesget_resource_activitiesauditread
GET/attributesGetAttributesget_attributescoreread
POST/attributesAddAttributeadd_attributecorewrite
DELETE/attributes/{key}DeleteAttributedelete_attributecorewrite
GET/attributes/{key}GetAttributeget_attributecoreread
PATCH/attributes/{key}UpdateAttributeupdate_attributecorewrite
GET/attributes/{key}/allowedValuesGetAttributeAllowedValuesget_attribute_allowed_valuescoreread
GET/documentsGetDocumentsget_documentscoreread
POST/documentsAddDocumentadd_documentcorewrite
POST/documents/uploadAddDocumentUploadadd_document_uploadcorewrite
DELETE/documents/{documentId}DeleteDocumentdelete_documentcorewrite
GET/documents/{documentId}GetDocumentget_documentcoreread
PATCH/documents/{documentId}UpdateDocumentupdate_documentcorewrite
GET/documents/{documentId}/actionsGetDocumentActionsget_document_actionscoreread
POST/documents/{documentId}/actionsAddDocumentActionsadd_document_actionscorewrite
POST/documents/{documentId}/actions/retryAddDocumentRetryActionadd_document_retry_actioncorewrite
GET/documents/{documentId}/ai/promptsGetDocumentAiPromptsResultsget_document_ai_prompts_resultsairead
GET/documents/{documentId}/ai/prompts/{llmPromptEntityName}GetDocumentAiPromptResultsget_document_ai_prompt_resultsairead
GET/documents/{documentId}/artifactsGetDocumentArtifactsget_document_artifactscoreread
GET/documents/{documentId}/attributesGetDocumentAttributesget_document_attributescoreread
POST/documents/{documentId}/attributesAddDocumentAttributesadd_document_attributescorewrite
PUT/documents/{documentId}/attributesSetDocumentAttributesset_document_attributescorewrite
DELETE/documents/{documentId}/attributes/{attributeKey}DeleteDocumentAttributedelete_document_attributecorewrite
GET/documents/{documentId}/attributes/{attributeKey}GetDocumentAttributeget_document_attributecoreread
PUT/documents/{documentId}/attributes/{attributeKey}SetDocumentAttributeValueset_document_attribute_valuecorewrite
DELETE/documents/{documentId}/attributes/{attributeKey}/{attributeValue}DeleteDocumentAttributeAndValuedelete_document_attribute_and_valuecorewrite
GET/documents/{documentId}/contentGetDocumentContentget_document_contentcoreread
GET/documents/{documentId}/fulltextGetDocumentFulltextget_document_fulltextfulltextread
GET/documents/{documentId}/malwareScanGetMalwareScanResultsget_malware_scan_resultsmalwareread
GET/documents/{documentId}/ocrGetDocumentOcrget_document_ocrocrread
POST/documents/{documentId}/ocrAddDocumentOcradd_document_ocrocrwrite
DELETE/documents/{documentId}/purgePurgeDocumentpurge_documentcorepurge
PUT/documents/{documentId}/restoreSetDocumentRestoreset_document_restorecorewrite
GET/documents/{documentId}/tagsGetDocumentTagsget_document_tagscoreread
PATCH/documents/{documentId}/tagsUpdateDocumentTagsupdate_document_tagscorewrite
POST/documents/{documentId}/tagsAddDocumentTagsadd_document_tagscorewrite
PUT/documents/{documentId}/tagsSetDocumentTagsset_document_tagscorewrite
DELETE/documents/{documentId}/tags/{tagKey}DeleteDocumentTagdelete_document_tagcorewrite
GET/documents/{documentId}/tags/{tagKey}GetDocumentTagget_document_tagcoreread
PUT/documents/{documentId}/tags/{tagKey}SetDocumentTagset_document_tagcorewrite
DELETE/documents/{documentId}/tags/{tagKey}/{tagValue}DeleteDocumentTagAndValuedelete_document_tag_and_valuecorewrite
GET/documents/{documentId}/uploadGetDocumentIdUploadget_document_id_uploadcorewrite
GET/documents/{documentId}/urlGetDocumentUrlget_document_urlcoreread
GET/documents/{documentId}/versionsGetDocumentVersionsget_document_versionscoreread
PUT/documents/{documentId}/versionsSetDocumentVersionset_document_versioncorewrite
DELETE/documents/{documentId}/versions/{versionKey}DeleteDocumentVersiondelete_document_versioncorewrite
POST/documents/{documentId}/workflow/{workflowId}/decisionsAddDocumentWorkflowDecisionsadd_document_workflow_decisionsworkflowswrite
GET/documents/{documentId}/workflowsGetDocumentWorkflowsget_document_workflowsworkflowsread
POST/documents/{documentId}/workflowsAddDocumentWorkflowadd_document_workflowworkflowswrite
GET/documents/{documentId}/workflows/{workflowId}GetDocumentWorkflowget_document_workflowworkflowsread
GET/foldersGetFolderDocumentsget_folder_documentscoreread
POST/foldersAddFolderadd_foldercorewrite
POST/indices/searchIndexSearchindex_searchcoreread
GET/permissions/catalogGetPermissionCatalogget_permission_catalogcoreread
GET/queuesGetQueuesget_queuesworkflowsread
GET/queues/{queueId}GetQueueget_queueworkflowsread
GET/queues/{queueId}/documentsGetWorkflowQueueDocumentsget_workflow_queue_documentsworkflowsread
POST/searchDocumentSearchsearch_documentscoreread
POST/searchFulltextSearchFulltextsearch_fulltextfulltextread
GET/sitesGetSitesget_sitescoreread
GET/sites/{siteId}/classificationsGetSitesClassificationsget_sites_classificationscoreread
GET/sites/{siteId}/classifications/{classificationId}GetClassificationget_classificationcoreread
GET/sites/{siteId}/classifications/{classificationId}/attributes/{key}/allowedValuesGetClassificationAttributeAllowedValuesget_classification_attribute_allowed_valuescoreread
GET/sites/{siteId}/schema/documentGetSitesSchemaget_sites_schemacoreread
GET/sites/{siteId}/schema/document/attributes/{key}/allowedValuesGetSitesSchemaAttributeAllowedValuesget_sites_schema_attribute_allowed_valuescoreread
GET/versionGetVersionget_versioncoreread
GET/workflowsGetWorkflowsget_workflowsworkflowsread
GET/workflows/{workflowId}GetWorkflowget_workflowworkflowsread
GET/workflows/{workflowId}/documentsGetWorkflowDocumentsget_workflow_documentsworkflowsread

The explicit operation registry is in formkiq_mcp/operations.py; access is assigned by effect, not HTTP verb or name. GetDocumentIdUpload is a write because it grants upload capability, while IndexSearch is a read despite using POST. requiredPermission is preserved from the upstream spec for guidance; FormKiQ remains the authority for permissions.

Startup rejects specs with missing catalog operations, duplicate operation IDs, or unresolved/external references. Custom documents must include all 69 supported operations, use OpenAPI 3.0, and use JSON request bodies.

API Groups and Installed Modules

The default API group is core, which is always included. Additional API groups are opt-in:

API groupOperationsDeployment capability
coreDocument and attribute operations, folders/index search, site discovery, site schemas/classificationsCommon API endpoints; backend permissions still apply
ocrGetDocumentOcr, AddDocumentOcrTesseract is available without an add-on; Textract-specific options require textract
fulltextSearchFulltext, GetDocumentFulltextopensearch
aiGetDocumentAiPromptsResults, GetDocumentAiPromptResultsai (reported dataclassification is recognized)
malwareGetMalwareScanResultsmalware (reported antivirus/malwarescan are recognized)
workflowsWorkflow/queue inspection, starting document workflows, submitting decisionsworkflows (reported workflow is recognized)
auditGetResourceActivitiesExplicit API group opt-in; backend GOVERN_USER_ACTIVITIES permission
export FORMKIQ_API_GROUPS="core,ocr,fulltext,ai,malware,workflows"

Leaving FORMKIQ_API_GROUPS unset or empty selects only core.

Installed modules are discovered automatically at startup. When an endpoint and JWT are configured, the server makes one read-only GetVersion request, with a five-second overall timeout, before serving the first tool list. You do not need to call get_version manually to expose module-backed tools. Only selected API Groups are exposed, and write/purge flags and caller grants still apply.

For hosted HTTP, startup discovery uses the first configured caller whose operation allowlist includes GetVersion, with that caller's downstream JWT. If no caller grants GetVersion, discovery is skipped; it does not fall back to the global JWT to bypass caller policies. Allow GetVersion for a discovery caller, or declare installed capabilities with FORMKIQ_MODULES.

Discovery failures do not prevent startup. Missing credentials, authorization failures, unreachable endpoints, and invalid module responses are reported on stderr. Selected groups with missing capabilities are also named, with a reminder to declare installed but unadvertised modules. Explicit FORMKIQ_MODULES declarations remain effective even if discovery fails. Unknown module names are ignored.

For stdio clients, pass optional settings through the client's environment table or allowlist, or use .env, then restart the child server. To disable startup discovery for offline use or fully explicit configuration:

FORMKIQ_AUTO_DISCOVER=false

You can still call get_version to retry failed discovery or refresh capabilities after the backend changes. Then refresh the client's tool list (MCP tools/list); clients that cache tools may need a manual refresh, as the server does not send tool-list change notifications. Automatic discovery runs once per server lifespan, rather than on every request.

Some deployments do not advertise every feature in GetVersion.modules. Declare those installed capabilities explicitly:

export FORMKIQ_MODULES="workflows"

Supported capability names include opensearch, typesense, textract, ai, malware, and workflows. Versioned identifiers such as opensearch_2.19.2 are recognized. Explicit declarations supplement discovered modules; they do not install features or grant permissions. Read-only configuration remains the default even when all optional API groups are selected. DocumentSearch remains in core; its structured and JSON predicates do not require OpenSearch.

Administration, integrations, deprecated processing APIs, and public/provider callback endpoints are outside this version's catalog.

Search, Counts, and Explicit Deletion

search_documents accepts body, siteId, next, previous, limit (a string, as defined by the API), and projection (DOCUMENTS or COUNT). Use describe_operation("DocumentSearch") for multi-attribute and nested JSON examples. Continue document pagination while next is present, even if a filtered page contains no matches.

Example count_documents arguments:

{"body":{"query":{"attribute":{"key":"invoiceDetails","json":{"path":"$.total","gte":1000}}}},"siteId":"default"}

The count helper uses the existing DocumentSearch endpoint with projection=COUNT. It preserves body.count and body.truncated and adds countIsExact. A truncated count is a lower bound, capped at 10,000 or stopped by the backend processing budget. COUNT has no continuation tokens, and the helper never aggregates partial counts. Invalid or older backend responses are reported as errors rather than treated as exact totals.

When writes are enabled, delete_document requires an explicit deleteType: SOFT_DELETE, HARD_DELETE, or CONTENT_ONLY. The generic write tool also requires deleteType for DeleteDocument, or an explicit legacy softDelete boolean. CONTENT_ONLY preserves metadata and historical S3 versions; permanent historical removal still uses the separately enabled purge tool.

The dedicated get_folder_documents tool accepts a folder path directly as path. For generic calls, folder paths use args.query.path; args.path is reserved for URL path parameters. Upload/download acceleration remains available as the accelerate parameter on URL operations.

Generic Tool Shape

call_formkiq_operation accepts nested arguments or unambiguous top-level parameter names. Unknown/conflicting arguments, missing required values, invalid types, and path dot segments are rejected before sending requests. Request bodies follow the schema returned by describe_operation; unknown body fields follow that schema’s additionalProperties rule.

Nested example:

{
  "operation_id": "GetDocument",
  "args": {
    "path": {
      "documentId": "abc-123"
    },
    "query": {
      "siteId": "default"
    }
  }
}

For request bodies:

{
  "operation_id": "DocumentSearch",
  "args": {
    "query": {
      "siteId": "default"
    },
    "body": {
      "query": {
        "text": "invoice"
      }
    }
  }
}

Local Codex Development Setup

For local development from a checkout, use uv in ~/.codex/config.toml or in a trusted project's .codex/config.toml:

[mcp_servers.formkiq]
command = "uv"
args = ["run", "--locked", "python", "server.py"]
cwd = "/Users/you/Documents/github/formkiq-mcp-server"
env_vars = ["FORMKIQ_API_ENDPOINT_URL", "FORMKIQ_JWT", "FORMKIQ_API_GROUPS", "FORMKIQ_MODULES", "FORMKIQ_AUTO_DISCOVER", "FORMKIQ_ENABLE_WRITES", "FORMKIQ_ENABLE_PURGE"]
startup_timeout_sec = 30
tool_timeout_sec = 60
enabled = true

[mcp_servers.formkiq.env]
MCP_TRANSPORT = "stdio"

If you want to pin the spec to a local checkout, add:

FORMKIQ_OPENAPI_FILE = "/Users/you/Documents/github/formkiq-core/docs/openapi/openapi-jwt.yaml"

Then start a new Codex session and check:

/mcp

You can also verify from a shell:

codex mcp list

Codex MCP configuration reference: https://developers.openai.com/codex/mcp

Claude Code Project Setup

For a project-shared Claude Code setup from a local checkout, add a .mcp.json file to your project:

{
  "mcpServers": {
    "formkiq": {
      "type": "stdio",
      "command": "uv",
      "args": ["--directory", "/Users/you/Documents/github/formkiq-mcp-server", "run", "--locked", "python", "server.py"],
      "env": {
        "MCP_TRANSPORT": "stdio",
        "FORMKIQ_API_ENDPOINT_URL": "https://abc123.execute-api.us-east-1.amazonaws.com",
        "FORMKIQ_JWT": "eyJ..."
      }
    }
  }
}

Then run:

claude mcp list

Inside Claude Code, use:

/mcp

Claude Code MCP docs: https://docs.anthropic.com/en/docs/claude-code/mcp

Claude Desktop Setup

Claude Desktop uses claude_desktop_config.json.

Config file locations:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json

Example:

{
  "mcpServers": {
    "formkiq": {
      "command": "uv",
      "args": ["--directory", "/Users/you/Documents/github/formkiq-mcp-server", "run", "--locked", "python", "server.py"],
      "env": {
        "MCP_TRANSPORT": "stdio",
        "FORMKIQ_API_ENDPOINT_URL": "https://abc123.execute-api.us-east-1.amazonaws.com",
        "FORMKIQ_JWT": "eyJ..."
      }
    }
  }
}

Restart Claude Desktop after editing the config. If the MCP server does not appear, check Claude Desktop's MCP logs:

  • macOS: ~/Library/Logs/Claude
  • Windows: %APPDATA%\Claude\logs

Claude Desktop local MCP setup docs: https://modelcontextprotocol.io/docs/develop/connect-local-servers

MCP Inspector

Run the HTTP server:

uv run --locked python server.py

Then start the inspector:

npx -y @modelcontextprotocol/inspector

Connect to:

http://localhost:8000/mcp

Write and Purge Access

Read-only access is the default. To expose dedicated write tools such as add_document, add_document_tags, and delete_document, along with call_formkiq_write_operation:

export FORMKIQ_ENABLE_WRITES=true

Read tools continue to reject mutations. Permanent purge is enabled separately and exposes purge_document:

export FORMKIQ_ENABLE_WRITES=true
export FORMKIQ_ENABLE_PURGE=true

Restart the server after changing configuration. MCP clients should request user approval for destructive actions; tool annotations identify reads and mutations. Server-side flags and caller policies enforce access independently of client annotations.

Migration from v0.1.0: endpoints now have dedicated tools with full OpenAPI input schemas. Existing get_version, get_documents, get_document, and search_documents names remain available; generic tools also remain supported. SearchFulltext requires the fulltext API group and an OpenSearch capability; GetResourceActivities requires the audit API group. Document deletion requires an explicit mode. Custom OpenAPI files must cover 69 operations. Mutations use their dedicated tools or the generic write tool, and purge continues to require both flags and purge_document. HTTP tool listings are filtered to each caller's grants.

Response Handling and Limits

Responses retain operationId, method, statusCode, ok, and body. Full request URLs are omitted to avoid exposing share keys. Upstream API failures produce MCP isError: true, preserving the HTTP status, bounded response body, and Retry-After when present. Invalid JSON, unsupported binary content, transport failures, and timeouts also produce tool errors. A read operation with a declared download redirect returns a validated body.contentUrl without following the redirect or forwarding the FormKiQ JWT. Accepted processing responses preserve the backend status and body; they are not polled automatically. Issuing an upload URL does not complete the upload, and an accepted OCR/job request does not imply completion. Writes are never retried automatically.

FORMKIQ_MAX_RESPONSE_BYTES defaults to 65536 (64 KiB), with a supported range of 1 KiB–10 MiB. The proxy stops reading oversized decoded responses, closes the stream, and returns an explicit error. It also limits serialized tool payloads and operation descriptions. Request fewer results, follow pagination tokens, or use GetDocumentUrl for large content. The explicitly requested full OpenAPI resource is exempt from this limit; use describe_operation for focused schemas.

HTTP Caller Authentication

Local HTTP binds to 127.0.0.1:8000 by default. FORMKIQ_MCP_HOST and FORMKIQ_MCP_PORT configure the listener. Non-loopback HTTP refuses to start without FORMKIQ_MCP_AUTH_FILE. A reverse proxy that exposes a loopback listener publicly must also use caller authentication.

HTTP authentication uses preconfigured MCP bearer tokens. Configure the token manually in the MCP client; this mode does not provide an OAuth authorization server or automatic OAuth login. MCP tokens are distinct from downstream FormKiQ JWTs and are never forwarded to FormKiQ.

Generate a high-entropy token and its SHA-256 hash:

python3 - <<'PYTOKEN'
import hashlib
import secrets
token = secrets.token_urlsafe(32)
print("MCP client token:", token)
print("token_sha256:", hashlib.sha256(token.encode()).hexdigest())
PYTOKEN

Store only the hash in a private policy file:

{
  "clients": [
    {
      "id": "analyst",
      "token_sha256": "<64-character-lowercase-sha256>",
      "jwt_env": "FORMKIQ_ANALYST_JWT",
      "allowed_operations": ["GetVersion", "GetSites", "GetDocuments", "GetDocument", "DocumentSearch"],
      "allowed_sites": ["tenant-a"]
    }
  ]
}
export FORMKIQ_MCP_AUTH_FILE="/private/path/formkiq-callers.json"
export FORMKIQ_ANALYST_JWT="<FormKiQ JWT scoped to this caller>"
export FORMKIQ_MCP_HOST="0.0.0.0"
uv run --locked python server.py

Each request requires Authorization: Bearer <MCP client token>. Policies restrict operation IDs and site IDs in both path and query parameters, and each caller maps to its own downstream JWT variable. For HTTP callers, GetSites returns only allowed site summaries (siteId, title, status, roles, permissions), excluding global claims and site configuration. Explicit indexName overrides are disabled for HTTP callers to preserve site isolation. Missing siteId means default, which must be explicitly authorized; a tenant-specific caller should supply its site. Global write/purge flags remain required even if a caller policy lists those operations. Policy files load at startup; restart to rotate tokens or policies. Use least-privilege downstream JWTs and replace them when they expire.

HTTP uses stateless MCP requests so caller identity remains attached to each request. A single async HTTP client is reused for the application lifespan. Requests have a 10-second connect timeout and 30-second network-operation timeout.

Security and Hosting

  • Use the CloudFormation HttpApiUrl endpoint for JWT authentication. IAM signing and API-key authentication are not implemented.
  • FormKiQ endpoints require HTTPS, except loopback HTTP for local development.
  • Do not commit JWTs, MCP bearer tokens, or private caller-policy files. Prefer environment variables and secret management.
  • Operation audit records go to stderr and include caller ID, operation ID, outcome, status, and duration. Bodies, document IDs, query parameters, and credentials are excluded.
  • Place hosted HTTP behind TLS and configure caller authentication, authorization, and infrastructure rate limits. Use a long-running ASGI-compatible host such as ECS or App Runner. Lambda/API Gateway deployments require an appropriate ASGI adapter and timeout configuration.

Development and Verification

uv sync --locked
uv run --locked ruff check .
uv run --locked ruff format --check .
uv run --locked python -m unittest discover -v
uv build

Tests validate all 69 generated endpoint schemas and route all 29 added endpoints through their dedicated tools. They cover .env startup and environment precedence, automatic module discovery before the initial tool list, discovery failures/timeouts/cancellation, explicit operation effects, caller-specific tool discovery and cached-tool authorization, API group/module gating and revocation, path/query/header/body routing, recursive schemas, site isolation, filtered site discovery, nested JSON search, count truncation, deletion modes, download redirects, async acceptance, response limits, concurrency, HTTP transport, and stdio startup. Backend requests are mocked. CI runs the locked environment on Python 3.11 and 3.14, then installs the wheel in an isolated environment and checks the console entry point, generated tool schemas, and bundled resource.

When updating the bundled spec, use an immutable upstream commit, update formkiq_mcp/data/provenance.json with the source and SHA-256, and run the suite. Keep the upstream Apache-2.0 license attribution in that file.

Release tags use vMAJOR.MINOR.PATCH and match [project].version in pyproject.toml (for example, package version 0.1.0 uses tag v0.1.0). Before publishing a release, update the package version, regenerate uv.lock, update the installation examples to the matching tag, and run the verification steps above. Keep published release tags fixed to their original commits.

PYPI
formkiq-mcp-server
Install Command
pip install formkiq-mcp-server
Runtime: uvx