Docs

A living knowledge base for studies, tests, and platform workflows.
PublishedUpdated: 11/8/20266 min readIntegrations

MCP and agent connections

A practical guide to connecting an AI agent to the production MCP endpoint, with tools, resources, version publishing, and image uploads.
In this article
  1. 01
    Connect Claude, ChatGPT, or Codex
  2. 02
    Production endpoint
  3. 03
    What you need
  4. 04
    Minimal JSON-RPC exchange
  5. 05
    Abilities and access boundaries

Connect Claude, ChatGPT, or Codex

Open Settings -> API & MCP -> MCP Connections. The Connect an AI client panel provides buttons for Claude and ChatGPT, plus the Codex command:

codex mcp add --transport http psylab https://psylab-research.org/mcp/psylab

For a client without OAuth connector support, use manual setup: create an agent connection, copy the Bearer token, and store it as a secret. Start with the Default preset and add scopes only when needed.

Quick MCP client connection

Write access requires mcp:write and the relevant domain scope. Individual respondent data is enabled separately: name the AI client, select a specific study or test, and confirm the disclosure basis.

Connector permissions and respondent-data access\n\n# MCP and agent connections

Psylab provides an authenticated MCP server for studies, tests, questions, analytics, and administrative content. MCP is intended for integrations and AI agents; a participant does not need to take a test through this endpoint.

Production endpoint

https://psylab-research.org/mcp/psylab

For another environment, use the same application host with the /mcp/psylab path.

What you need

  1. Open /settings/api-mcp.
  2. Create an agent token and enable mcp:use.
  3. For writes, add mcp:write and the abilities for the domains that must change.
  4. For participant data, configure mcp:respondent-data separately and select concrete disclosure targets.
  5. Copy the plaintext token once and pass it to your MCP client as a secret.

The token must have the mcp audience and the plan capability mcp_access. A REST API token with the api audience is not valid for this endpoint.

Minimal JSON-RPC exchange

An MCP client performs initialize, stores the returned Mcp-Session-Id header, and sends that header with subsequent requests. A minimal tools-list check looks like this:

MCP_URL="https://psylab-research.org/mcp/psylab"
MCP_TOKEN="TOKEN_HERE"
MCP_SESSION_ID="SESSION_ID_FROM_INITIALIZE"

curl -sS -X POST "$MCP_URL" \
  -H "Authorization: Bearer $MCP_TOKEN" \
  -H "Mcp-Session-Id: $MCP_SESSION_ID" \
  -H "Accept: application/json, text/event-stream" \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}'

A tool call looks like this:

{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "psylab.list_tests",
    "arguments": { "limit": 20 }
  }
}

The response contains a JSON-RPC result; tool errors normally arrive as result.isError: true. Never print the bearer token in logs.

Abilities and access boundaries

Every call passes through the token audience, plan capability, mcp:use, object access, and the ability required by the specific tool.

Scenario Requirements
Profile and structure reads mcp:use + profile:read / studies:read / tests:read / questions:read.
Create or update a study mcp:use + mcp:write + studies:write.
Create or update a test mcp:use + mcp:write + tests:write.
Create or update a question mcp:use + mcp:write + questions:write.
Publish a version The same domain write abilities; publishing creates an immutable version.
Aggregate analytics mcp:use + analytics:read.
Respondents/results The relevant read/write ability and mcp:respondent-data, plus a separate grant.
Documentation, blog, media, changelog An admin account and the relevant content abilities; writes also require mcp:write.

Tools

Studies and versions

  • psylab.list_studies, psylab.get_study
  • psylab.create_study, psylab.update_study
  • psylab.list_study_versions, psylab.publish_study_version

Tests and questions

  • psylab.list_tests, psylab.get_test
  • psylab.create_test, psylab.update_test
  • psylab.list_test_versions, psylab.publish_test_version
  • psylab.attach_test_to_study
  • psylab.list_questions, psylab.create_question, psylab.update_question, psylab.reorder_questions

Supported question types are single, multiple, open, range, rating, boolean, dropdown, nps, scale, email, phone, date, and matrix.

Participant data and analytics

  • psylab.list_respondents, psylab.create_respondent, psylab.update_respondent
  • psylab.list_results
  • psylab.get_test_analytics, psylab.get_study_analytics

list_respondents requires study_id; list_results requires test_id. Analytics remains aggregate: for a sample below five, the result is returned without disclosed statistics.

Administrative content

  • Blog: list_blog_articles, get_blog_article, create_blog_article, update_blog_article, publish_blog_article
  • Documentation: list_documentation_pages, get_documentation_page, create_documentation_page, update_documentation_page, publish_documentation_page
  • Media: list_media, create_media_upload
  • Changelog: list_changelog_entries, get_changelog_entry, create_changelog_entry, update_changelog_entry, publish_changelog_entry

Resources

Available resource URIs:

URI Purpose
psylab://me Current account and token abilities; requires profile:read.
psylab://studies Recent accessible studies; requires studies:read.
psylab://studies/{study_id} One study with tests and counts; requires studies:read.
psylab://studies/{study_id}/analytics Privacy-filtered study analytics; requires analytics:read.
psylab://tests/{test_id} One test with questions and options; requires tests:read.
psylab://tests/{test_id}/questions Questions and options; requires questions:read.
psylab://tests/{test_id}/results Minimized results with results access and a disclosure grant.
psylab://respondents/{respondent_id} Minimized respondent context with respondent access and a disclosure grant.

Prompts

The server publishes prompts for common research tasks:

  • create-study-plan
  • generate-test-questions
  • review-test-quality
  • improve-question-wording
  • analyze-study-results
  • prepare-research-summary

Prompts help prepare a payload, but they do not replace a researcher's methodological review.

Recommended write flow

  1. Call psylab.list_tests and psylab.list_studies to avoid duplicates.
  2. Create a test with psylab.create_test.
  3. Read the current draft revision with psylab.list_test_versions.
  4. Add questions with psylab.create_question; send the current revision with each write.
  5. Configure scoring version 2 when needed.
  6. Publish the test with psylab.publish_test_version.
  7. Create or update the study, attach the test, and publish the study version.
  8. After any concurrent change, read the revision again: a stale revision is rejected to protect newer edits.

Creating an entity and publishing it are separate operations. Always verify the published version before sharing a public link.

Upload images for documentation

Only an admin MCP token with mcp:write and media:write can call psylab.create_media_upload. The tool returns a one-use ticket valid for 10 minutes for PNG, JPEG, or WebP images up to 8 MiB.

Then send the bytes directly:

curl -sS -X POST "https://psylab-research.org/media/agent-upload" \
  -H "X-Media-Upload-Ticket: TICKET_FROM_MCP" \
  -H "Content-Type: image/jpeg" \
  --data-binary @screenshot.jpg

Multipart with the image field is also supported. A successful upload returns a public asset URL; the ticket is one-use, so do not repeat an uncertain request without checking the media library.

Question types builder in the English UI

Privacy and audit

Do not put participant contact details, free text, or real secrets into prompts or tool arguments unless the task requires them. Every tool/resource call writes a technical audit row, and revoking a token stops future access but cannot retract data already sent to an agent.

Need help?

We are ready to help with research setup, access, or methodology configuration.
Average response time: 1 business day