Skip to main content
Menu

How to build an MCP server: start from your existing web service

This guide walks through choosing one action from your existing web service’s API, publishing it as an MCP server with andpipe, and trying it from AI. The integration guide covers each step in detail.

1. Who this is for and what you need

For developers who want to make the API of a web service or SaaS they run usable from AI. Prepare these three things before you start.

  • An API that accepts actions from external apps
  • OAuth for user sign-in (if you don’t have it, add it with andpipe’s OAuth Kit)
  • An andpipe admin console account and a project
Vibe coding? Prompt to paste into the AI developing your own service: prepare the API and OpenAPI specification

Do not paste real API keys, secrets, or personal data. Review the AI’s proposed changes before applying them.

Prompt for the AI developing your service

You are the development AI working in the repository of our own web service / SaaS, built with Cursor / Claude Code / Codex / Antigravity or similar tools. First inspect the existing codebase, present a change plan, and obtain the responsible developer’s approval before implementing the approved scope. Do not change production settings or the existing database without authorization.

Prepare our service’s public API and OpenAPI specification for integration with andpipe.

Investigation and implementation:
- Inspect the framework, routing, authentication, tenant / access boundary (such as an organization, location, store, factory, or work site) / role authorization checks, and existing OpenAPI generation. Define business-level endpoints that AI may use instead of exposing the entire internal API or database unchanged.
- Provide at least one read API for connection diagnostics after publication: require the appropriate scope, allow no side effects (no saving, changing, or sending data), and accept no required parameters (empty input {} / no arguments). An account or service status summary is suitable. Return no raw PII or secret values.
- Deny POST and other writes by default. Public execution is limited to bounded updates with a side-effect-free read preview (a dry-run that saves, changes, or sends nothing) and an atomic expected_version compare-and-swap (CAS) check that updates only the reviewed version, as a preview/apply pair. Require explicit approval before execution and idempotency using Idempotency-Key or request_id. Mutable drafts, bulk writes, writes without CAS or review_binding, and destructive APIs such as deletion or cancellation cannot execute publicly.
- Write openapi.yaml at the repository root in OpenAPI 3.1 (or 3.0), no larger than 512 KiB. Specify a public HTTPS servers URL consistent with the API base URL excluding paths such as /v1, operationId for every operation, input/output JSON Schema, and OAuth securitySchemes and scopes.

Safeguards:
- Never paste or hard-code real API keys, client secrets, service account keys, private keys, access tokens, refresh tokens, raw personal data (PII), or raw business data in chat, code, openapi.yaml, Markdown, or git diff. Reference secrets through environment variables and use only fictional example data.
- Do not accept or forward the token sent by the AI host to andpipe directly at our API (No Token Passthrough). Validate the audience / resource and scope dedicated to our API.
- Do not change the existing business database schema, authorization model, or production configuration without explicit approval from the responsible developer. Ask for missing information instead of guessing.

Completion criteria:
- Report changed files, verification commands and results, and checks that failed or were not run. Local validation alone does not prove a live connection or publication.
- Identify the openapi.yaml to select in andpipe Admin, the connected service’s API base URL to enter or verify, and the diagnostic operationId / scope.

2. Choose one read action from your existing API

Start with a single read action that doesn’t change data. For connection diagnostics, choose an action that has the required permission (scope), has no side effects and can be called with empty input {}. For example, a status API you can call without arguments. Actions with required inputs cannot be used for diagnostics.

If your API is described in OpenAPI, you can import it as the basis for the action definitions.

Vibe coding? Prompt to paste into the AI developing your own service: check diagnostic read APIs and safe update APIs

Do not paste real API keys, secrets, or personal data. Review the AI’s proposed changes before applying them.

Prompt for the AI developing your service

You are the development AI working in the repository of our own web service / SaaS, built with Cursor / Claude Code / Codex / Antigravity or similar tools. First inspect the existing codebase, present a change plan, and obtain the responsible developer’s approval before implementing the approved scope. Do not change production settings or the existing database without authorization.

Inspect and adapt our API endpoints intended for AI through andpipe to meet safety requirements and support read diagnostics after publication.

Investigation and implementation:
- Inspect the endpoints, authentication, and tenant / access boundary (such as an organization or location) / role authorization. Ensure at least one read API requires the appropriate scope, has no side effects (no saving, changing, or sending data), and accepts no required arguments (empty input {}). If all existing APIs require arguments, add a separate argument-free read API for diagnostics.
- Check response schemas and implementations for every exposed API. Mask or remove raw PII such as email addresses, phone numbers, and addresses, as well as tokens and internal secret fields.
- Deny POST and other writes by default. Public execution is limited to bounded updates with a side-effect-free read preview (a dry-run that saves, changes, or sends nothing) and an atomic expected_version compare-and-swap (CAS) check that updates only the reviewed version, as a preview/apply pair. Require explicit approval before execution and idempotency using Idempotency-Key or request_id. Mutable drafts, bulk writes, writes without CAS or review_binding, and destructive APIs such as deletion or cancellation cannot execute publicly.
- Synchronize paths, input/output schemas, and scopes in the root openapi.yaml. Verify reads have no side effects, sensitive output is removed, unapproved writes are denied, and repeated execution is prevented.

Safeguards:
- Never paste or hard-code real API keys, client secrets, service account keys, private keys, access tokens, refresh tokens, raw personal data (PII), or raw business data in chat, code, openapi.yaml, Markdown, or git diff. Reference secrets through environment variables and use only fictional example data.
- Do not accept or forward the token sent by the AI host to andpipe directly at our API (No Token Passthrough). Validate the audience / resource and scope dedicated to our API.
- Do not change the existing business database schema, authorization model, or production configuration without explicit approval from the responsible developer. Ask for missing information instead of guessing.

Completion criteria:
- Report changed files, verification commands and results, and checks that failed or were not run. Local validation alone does not prove a live connection or publication.
- List the operations and scopes to register in andpipe Admin’s “Actions available to AI”, the preview and approval settings, and the read operation to select for diagnostics.

3. Define inputs, outputs and permissions in a Tool Contract

For the chosen action, record in a Tool Contract the input it accepts, the format of the result it returns, its risk level, the required permissions, the confirmation conditions and the logging rules. Only actions allowed by this definition are exposed to AI.

Actions that update or delete data are not allowed by default. To add one, define a pre-execution trial, explicit approval and protection against duplicate execution.

4. Check OAuth and the connected service

When connecting from AI, you sign in and allow (consent to) use from AI. If your existing OAuth meets the connection requirements, use it as is; if you have no usable authorization server, add one with OAuth Kit.

Credentials that reach andpipe from AI are never passed unchanged to the connected API. The connected API uses separate credentials, each limited to its own purpose and target.

End users can connect only in projects where end-user connections are activated under “End-user connections”. They can use the read and draft actions approved for publishing. Changes are applied by the users themselves on your service’s confirmation screen.

Details in step 8 of the integration guide

Vibe coding? Prompt to paste into the AI developing your own service: prepare OAuth sign-in integration

Do not paste real API keys, secrets, or personal data. Review the AI’s proposed changes before applying them.

Prompt for the AI developing your service

You are the development AI working in the repository of our own web service / SaaS, built with Cursor / Claude Code / Codex / Antigravity or similar tools. First inspect the existing codebase, present a change plan, and obtain the responsible developer’s approval before implementing the approved scope. Do not change production settings or the existing database without authorization.

Prepare our service’s OAuth integration for andpipe’s “Sign-in and permissions” settings.

Investigation and implementation:
- Check whether an OAuth 2.0 authorization server already exists. Verify a public HTTPS Issuer URL, /.well-known/oauth-authorization-server, /.well-known/jwks.json, authorization code + PKCE (S256), exact-match Redirect URI registration, a revocation_endpoint for disconnection, resource / audience matching the API base URL, and publication of allowed scopes.
- If no usable authorization server exists, propose the public @andpipes/oauth-kit package with createUpstreamAuthorizationServer and verifyUpstreamAccessToken, then wire it to the existing sign-in UI and sessions after approval. In either case, put the IDs of the access boundary the user selected (such as an organization, location, store, factory, or work site) in authorization_details.boundaryIds of the introspection response, and return the label shown on the consent screen (for example, Store or Factory) in andpipe_display.boundaryKind (if omitted, “Access boundary” is shown; @andpipes/oauth-kit supports this from 0.4.0). Check the latest tenant, access boundary, role, and permissions at access time.
- Do not use sample in-memory storage, test accounts, or temporary keys in production. Add a dedicated persistent OAuth store only after design approval. Validate the API-specific audience / resource and scope and synchronize the OAuth definitions in openapi.yaml.
- Verify authorization for a scoped, side-effect-free read API with no required arguments (empty input {}) for diagnostics after publication. Distinguish configuration checks from actual sign-in and read tests with a test account.

Safeguards:
- Never paste or hard-code real API keys, client secrets, service account keys, private keys, access tokens, refresh tokens, raw personal data (PII), or raw business data in chat, code, openapi.yaml, Markdown, or git diff. Reference secrets through environment variables and use only fictional example data.
- Do not accept or forward the token sent by the AI host to andpipe directly at our API (No Token Passthrough). Validate the audience / resource and scope dedicated to our API.
- Do not change the existing business database schema, authorization model, or production configuration without explicit approval from the responsible developer. Ask for missing information instead of guessing.

Completion criteria:
- Report changed files, verification commands and results, and checks that failed or were not run. Local validation alone does not prove a live connection or publication.
- Explain what to enter in andpipe Admin for the connected service’s API base URL and authorization server URL (Issuer URL) or Settings URL (OAuth metadata URL), and where to register the return Redirect URI. Do not include secret values.

5. Check before publishing

Check the local configuration and review the diff before publishing the action. After publishing, sign in for real with a test account and complete the read diagnostic.

The items to check before going live are collected in step 9 of the integration guide.

6. Try it from the AI you connect

Try the published read action from the AI you connect. How to register and the usage conditions differ for each AI.

Steps for each AI

Get started

Start by creating an account and preparing a project. Registering alone does not publish your service.