---
title: "Connect your own MCP server or REST endpoint"
description: "Connect an MCP server or a REST endpoint that you run, check that it works, give others access, see what a call costs, and remove the Connection."
url: "https://harnesty.com/en/docs/integrations"
language: "en"
kind: "docs"
updated: "2026-12-04"
summary:
  - "Create a Custom Connection with connection.create to reach an MCP server or a REST endpoint that you run."
  - "connection.get shows whether it works, and connection.operation.list lists the operations it offers."
  - "Share it with connection.share or a Mandate, so a Flow, an Agent or your script can call it with connection.invoke."
  - "Each call costs 1 Credit, which you can quote before the call, and the workspace audit log records it."
sources:
  - title: "Workspace REST and MCP reference"
    url: "https://harnesty.com/en/docs/workspace-reference"
  - title: "Model Context Protocol Specification"
    url: "https://modelcontextprotocol.io/specification/2026-07-28"
    read: "2026-11-25"
  - title: "OpenAPI Specification v3.1.2"
    url: "https://spec.openapis.org/oas/v3.1.2.html"
    read: "2026-11-25"
---

# Connect your own MCP server or REST endpoint

A Custom Connection lets a Flow (a process you define in Harnesty), an Agent (an AI worker in your Workspace) or your own script call an MCP server or a REST endpoint that you run.

## In short

- Create a Custom Connection with connection.create to reach an MCP server or a REST endpoint that you run.
- connection.get shows whether it works, and connection.operation.list lists the operations it offers.
- Share it with connection.share or a Mandate, so a Flow, an Agent or your script can call it with connection.invoke.
- Each call costs 1 Credit, which you can quote before the call, and the workspace audit log records it.

The Connection stores the server's address and keeps its credential in your Workspace's vault. It turns each tool or path of the server into an operation, one call that a caller can make. Each call runs under a Mandate, the signed record that someone may do something. Harnesty meters every call and records it in the workspace audit log.

You answer for the server. We answer for everything around the call: the check of who may call, the meter, the audit log entry and the check of the address.

## Before you start

- You need a Mandate to administer the Workspace. Creating a Custom Connection is an owner-level act, because you answer for the endpoint.
- The server must answer on a public address. Harnesty refuses a host that resolves to a private, loopback or link-local address.
- Have ready the credential that the server expects. A server that expects no credential takes none.

## Connect an MCP server

1. Call [`connection.create`](https://harnesty.com/en/docs/workspace-reference#connection.create@v1) with `kind` set to `custom`, a `resource` of the form `custom:<name>`, and a `name` that no other live Connection in the Workspace uses.
1. Give `settings` as a list of `name=value` entries: `endpointUrl`, the server's URL, and `confirmedHost`, the host of that URL. If the two hosts differ, Harnesty refuses the create.

```text
   endpointUrl=https://mcp.example.com/mcp
   confirmedHost=mcp.example.com
```

1. If the server expects a credential, add one more entry, `credential`. Its value is a JSON object: a bearer token or a set of headers.

```text
   credential={"scheme":"bearer","token":"<token>"}
   credential={"scheme":"headers","headers":{"<Name>":"<value>"}}
```

1. Harnesty checks the address, contacts the server and reads its tools. Each tool becomes one operation. A tool without the `readOnlyHint: true` annotation is a write operation.
1. The answer carries the new Connection's id and the count of its operations. You hold the ownership Mandate over the Connection.

Harnesty speaks MCP revision 2026-07-28. It refuses a server that does not speak this revision when you create the Connection.

## Connect a REST endpoint

1. Publish an OpenAPI 3.1 document of your API, in JSON, at a URL that Harnesty can fetch.
1. Call [`connection.create`](https://harnesty.com/en/docs/workspace-reference#connection.create@v1) as for an MCP server, but give `documentUrl`, the document's URL, in place of `endpointUrl`. `confirmedHost` must match the host of that URL.
1. If the API expects a credential, add a `credential` entry. Its value is a JSON object: an API key in a header, a bearer token, or basic credentials.

```text
   credential={"scheme":"apiKey","header":"<Name>","value":"<key>"}
   credential={"scheme":"bearer","token":"<token>"}
   credential={"scheme":"basic","username":"<user>","password":"<password>"}
```

Each path and method becomes one operation, named by its `operationId`. Every operation must declare an `operationId` that no other operation uses, or Harnesty refuses the create. A path that the document does not declare does not exist in Harnesty, so no caller can reach it. `GET` and `HEAD` are read operations, and every other method is a write, whatever the document says.

## Check that it works

- [`connection.get`](https://harnesty.com/en/docs/workspace-reference#connection.get@v1) shows the Connection's `status`. It reads `active` when the Connection works. Any other status means that the server refused the stored credential, did not answer, or sits at an address that Harnesty does not allow.
- [`connection.operation.list`](https://harnesty.com/en/docs/workspace-reference#connection.operation.list@v1) lists each operation by name, with its read-only flag. You pass each of these names to `connection.invoke`.

A tool that fails, changes shape or disappears is yours to repair. Harnesty returns the tool error to the caller and never retries the call.

## Change or refresh a Connection

- [`connection.update`](https://harnesty.com/en/docs/workspace-reference#connection.update@v1) changes the `name` or the `settings` of the Connection that you name in `connection`. A change to any settings entry must carry the `credential` entry again, or Harnesty refuses the update. This way a stored credential never reaches a host it was not given for. Harnesty checks the new settings against the server again, and the new credential replaces the stored one.
- [`connection.refresh`](https://harnesty.com/en/docs/workspace-reference#connection.refresh@v1) reads the server's tools or the OpenAPI document again and replaces the list of operations. Harnesty reads them again only when you call it.

## Give others access to a Connection

A Connection belongs to the member who created it. Every member of the Workspace can see that it exists and which operations it offers. To call an operation, a caller needs a Mandate that reaches the Connection.

- [`connection.share`](https://harnesty.com/en/docs/workspace-reference#connection.share@v1) gives another member, an Agent or a Team access, as a Mandate that you issue at the Connection. Set `connection` to the Connection's id and `subject` to the Principal, the member, Agent or Team that receives access. Set `permissions` to `read`, or to `read` and `write`, and `verbs` to the actions that the share gives out, such as `harnesty:connection.invoke`. Read reaches the read operations alone, and write reaches the write operations. You can never give more than your own Mandate holds, and you can never give the ownership.
- [`mandate.issue`](https://harnesty.com/en/docs/workspace-reference#mandate.issue@v1) issues a Mandate at the Connection that grants the action `harnesty:connection.invoke`, to any other Principal.
- [`mandate.revoke`](https://harnesty.com/en/docs/workspace-reference#mandate.revoke@v1) ends that access. The revoke also ends every Mandate issued beneath it.

The holder then calls an operation with [`connection.invoke`](https://harnesty.com/en/docs/workspace-reference#connection.invoke@v1). The call returns an Operation, the record that Harnesty keeps of the call until it ends, and the output arrives on it. Harnesty refuses a caller whose Mandate does not reach the operation. No Mandate hands the credential out: Harnesty makes the call with it.

## See what a call costs

A call through a Custom Connection costs 1 Credit per call, and 1 Credit = $0.01. [`connection.get`](https://harnesty.com/en/docs/workspace-reference#connection.get@v1) and [`connection.list`](https://harnesty.com/en/docs/workspace-reference#connection.list@v1) show the price of one call through each Connection. [`connection.invoke.quote`](https://harnesty.com/en/docs/workspace-reference#connection.invoke.quote@v1) quotes a call before you make it. The price and the quote both come from the same published rate.

## Remove a Connection

[`connection.remove`](https://harnesty.com/en/docs/workspace-reference#connection.remove@v1) removes a Connection. In the same act, Harnesty revokes every Mandate issued over it, so no caller reaches the server through it again. Its name is free for a new Connection. The stored credential stays in the vault until you delete it with [`object.delete`](https://harnesty.com/en/docs/workspace-reference#object.delete@v1), with `objectId` set to the Connection's id.

## Sources

1. [Workspace REST and MCP reference](https://harnesty.com/en/docs/workspace-reference)
1. [Model Context Protocol Specification](https://modelcontextprotocol.io/specification/2026-07-28), read 2026-11-25
1. [OpenAPI Specification v3.1.2](https://spec.openapis.org/oas/v3.1.2.html), read 2026-11-25
