Call your internal API from ChatGPT, Claude and Cursor
To call your internal API from an AI tool without handing it the key, put the API call in a qbash Task and store the key as a Secret. A Task is an AI cloud function written in Python that qbash hosts on secure cloud infrastructure. You add the qbash MCP server to ChatGPT, Claude, Cursor or Codex once, and each of them can then run the Task. The Task's Python only holds a reference to the key, so the key is never in a chat, in a client's config file or in the model's context.
Prerequisites
- A qbash account. The free plan has 100 runs a month and 3 Tasks, with no card.
- An API that qbash can reach at a public
httpsaddress. See Limits if yours is only reachable inside a private network. - A key or token for that API. The example uses a bearer token. Basic auth, a custom header and a query parameter are also supported.
- An AI tool that supports remote MCP servers, such as ChatGPT, Claude, Cursor or Codex.
1. Store the key as a Secret
Open Secrets in the qbash sidebar and click New secret. Name it ADMIN_API_TOKEN, paste the token into Value and click Create. Secret names start with a letter and use uppercase letters, numbers and underscores. qbash gives the Secret a slug, which is how Task code refers to it: the name in lowercase with dashes plus the first 4 characters of its ID, such as admin-api-token-3f9a. Copy yours from the Secrets page, because it ends in different characters.
Do this step in qbash yourself, so that the token never passes through a chat. qbash encrypts the value, and nobody can view it again from the Secrets page, including you. You can replace it later when you rotate the token. Using Secrets covers sharing and rotation.
2. Add the qbash MCP server to your AI tool
The official qbash MCP server is at https://mcp.qbash.com/mcp. Every client signs in with your qbash account over OAuth, so there is no qbash key to paste into the client either.
- ChatGPT. Turn on Developer mode under Settings → Apps & Connectors → Advanced settings. Then create a connector under Settings → Connectors with the URL above and OAuth authentication. On a Business, Enterprise or Edu workspace, an owner or admin adds it first.
- Claude. Go to Customize → Connectors, click + Add, choose Add custom connector and paste the URL. On a Team or Enterprise plan, an Owner adds it under Organization settings → Connectors first.
- Cursor. Add the server to
~/.cursor/mcp.jsonas{"mcpServers": {"qbash": {"url": "https://mcp.qbash.com/mcp"}}}, reload Cursor and sign in when it asks. - Codex. Run
codex mcp add qbash --url https://mcp.qbash.com/mcp, thencodex mcp login qbash.
The card has the full steps for each client, with install links where the client supports them.
Connect with OAuth
- 1In ChatGPT, open Plugins in the left sidebar, click "Add", and choose "Add custom MCP server".
- 2Enter a name, paste
https://mcp.qbash.com/mcpas the server URL, choose OAuth, and click "Create as a plugin". - 3Install the plugin from the Personal tab and complete the qbash sign-in.
- 4In a new chat, type @ and pick the plugin by its name.
Any personal plan can add one, including Free. In a Business, Enterprise or Edu workspace, if the option isn't there, talk to your workspace owner.
3. Ask your AI tool to build the Task
With the server connected, your AI tool can use the qbash task builder. Paste this prompt and change the endpoints to match your API:
Use qbash to build a Task called "Customer lookup".
Inputs: email (required), note (optional).
Steps:
1. GET https://admin.example.com/api/customers?email=<email>.
Send the qbash Secret admin-api-token-3f9a as a bearer token.
2. If the API returns 404, output {"email": <email>, "found": false}.
3. If it returns any other status of 400 or above, fail the run with the status code.
4. Otherwise output the customer's id, plan and status.
5. If note was given, POST {"text": <note>} to
https://admin.example.com/api/customers/<id>/notes with the same bearer
token, and add the new note's id to the output.
Read the token with qbash.secrets["admin-api-token-3f9a"] and pass it to
qbash.http.auth.bearer. Never ask me for the token's value.
Description for the Task: "Looks up a customer in the admin API by email and
optionally adds a note. Returns the plan and status."
The builder writes the Task in Python and saves it. Every save is a version that you can go back to. The description is what an assistant reads when it decides whether to call the Task, so say when to use it and what it returns.
Open the Task in qbash before the first run and check that ADMIN_API_TOKEN is listed under Secrets in the Package. A Secret has to be attached to a Task before the Task can use it. If it's missing, choose Add secret from the Package + menu, attach it and save.
The complete Task
This is the Task that the prompt above describes. You can also paste it into main.py in the task editor and add email and note as inputs.
BASE_URL = "https://admin.example.com/api"
# A reference to the Secret. qbash fills in the stored token when it sends the request.
auth = qbash.http.auth.bearer(qbash.secrets["admin-api-token-3f9a"])
email = (qbash.inputs.get("email") or "").strip()
note = (qbash.inputs.get("note") or "").strip()
if not email:
raise ValueError("The email input is required")
def as_json(body):
return json.loads(body) if isinstance(body, str) else body
# GET: look the customer up by email.
lookup = qbash.http.request(
"GET",
f"{BASE_URL}/customers?email={urllib.parse.quote(email)}",
auth=auth,
timeout=10000,
)
if lookup["status"] == 404:
qbash.output({"email": email, "found": False})
elif lookup["status"] >= 400:
raise RuntimeError(f"Customer lookup returned HTTP {lookup['status']}")
else:
customer = as_json(lookup["body"])
result = {
"email": email,
"found": True,
"id": customer["id"],
"plan": customer["plan"],
"status": customer["status"],
}
# POST: add a note to the customer, only when the caller sent one.
if note:
created = qbash.http.request(
"POST",
f"{BASE_URL}/customers/{customer['id']}/notes",
body={"text": note},
auth=auth,
timeout=10000,
)
if created["status"] >= 400:
raise RuntimeError(f"Adding the note returned HTTP {created['status']}")
result["note_id"] = as_json(created["body"])["id"]
qbash.output(result)
A few things about this code:
- There are no
importlines. Tasks don't allow them. TheqbashSDK and common standard library modules such asjsonandurllib.parseare already loaded. - HTTP goes through
qbash.http.request. It returns a dictionary withstatus,headersandbody. An error status doesn't raise on its own, so the Task checksstatusand raises. A raised error fails the run. timeoutis in milliseconds. The default is 30,000.- A dictionary passed as
bodyis sent as JSON. qbash.secrets["admin-api-token-3f9a"]returns a reference, and the stored value never enters the Python runtime. Pass the reference through unchanged. If you slice it, hash it or encode it, qbash can't resolve it. For other auth schemes, useqbash.http.auth.basic,qbash.http.auth.headerorqbash.http.auth.query. The SDK reference lists them.
4. Call it from ChatGPT, Claude, Cursor and Codex
Ask in plain words in any client that has the qbash server connected:
Look up [email protected] in the admin API with the Customer lookup Task.
The assistant finds the Task, sends email as the input and gets back what the Task passed to qbash.output. The same Task answers from every client, so there is one copy of the logic to maintain. The assistant only sees the Task's name, description, inputs and result. The token and the Python stay in qbash.
A Task is not tied to MCP. It can also run on a schedule, from an API call or from a webhook.
How teammates use it without seeing the key
qbash also lets you build custom MCP servers. They work as a permission layer for your teammates or agents.
- Open MCP Servers → New server, choose Add tools and select the Customer lookup Task.
- On Access, invite specific people with Can connect, or select Organization.
- Each teammate adds the server's address to their AI tool and signs in with their own qbash account.
Teammates can call the tool. They can't edit the Task's code, and they never receive the token. Every run uses the Secret that is attached to the Task, so think about what that token allows before you share the tool. The server's Logs tab shows who called each tool and when.
Limits
- The API needs a public address. qbash sends each request from its own servers and refuses private and internal addresses such as
10.0.0.5orlocalhost. A Task can't reach an API that only answers inside your company network. - Each HTTP request waits 30 seconds by default. Set
timeoutto change that. Responses over 50 MB are refused. - A run can last up to 15 minutes on the Free and Developer plans.
- A long run returns an execution ID first. Over MCP, a Task call waits about 45 seconds. If the run is still going, the client gets an execution ID and collects the result with a status tool.
- Plan and role limits on the client side still apply. On ChatGPT Business, Enterprise and Edu workspaces and on Claude Team and Enterprise plans, an owner or admin has to add a custom MCP server first.
This setup isn't the right fit when the assistant should explore your whole API freely. A Task exposes the calls that you wrote, with the inputs that you defined. That is usually the point with an internal API, but it means each new operation is a change to the Task or a new Task.
FAQ
How do I let ChatGPT or Claude call my private API without exposing the API key?
Store the key as a qbash Secret and make the API call from a Task. The assistant calls the Task over MCP and gets the result. The key is filled in by qbash when the request is sent, so it is never in the conversation or in the client's configuration.
Can the model read the key?
The Task's Python only holds a reference to the key, and qbash resolves the reference when it sends the HTTP request. The value never enters the Python runtime or the conversation. The value can't be viewed on the Secrets page after it's saved. The API that receives the key can still do whatever that key allows, so only send a Secret to a service you trust with it.
Do I have to run or host an MCP server?
qbash hosts it. You connect your AI tool to the official server at https://mcp.qbash.com/mcp, or to a custom server that you create in qbash for your team.
Can I use the same Task in ChatGPT, Claude and Cursor?
One Task serves every client that is connected to qbash. You connect each client once, and a change to the Task applies to all of them.
My API uses an API key header instead of a bearer token. Does that work?
Use qbash.http.auth.header("X-Api-Key", qbash.secrets["admin-api-token-3f9a"]) as the auth argument. Basic auth and query-parameter keys have their own helpers.
Can it reach an API behind our firewall or VPN?
A Task can only call a public address. If the API is private, you need a public entry point for it, such as an API gateway that checks the key.
How do I rotate the key?
Open the Secret, choose ⋯ → Edit, replace the value and save. Tasks that use the Secret send the new value on their next request, with no code change.
Next steps
- Expose your internal API to your AI tools shows the same pattern with an inline prompt added.
- Official MCP server lists every tool your AI client gets, including the task builder.
- MCP servers covers custom servers, access and logs.
- Using Secrets covers attaching, sharing and rotating Secrets.
- Moving a GPT Action before December 11 covers the custom GPT retirement.