OrgRelay

Code templates and the developer kit

Four templates that each serve MCP and REST compatible mode from one process, with tenant isolation, idempotency, error codes and validation already in place. Replace the sample data with your queries and keep the rest.

Download

File Size Contents
orgrelay-developer-kit-1.1.0.zip 92 KB Templates with Chinese or English comments, spec files, self-test tool, developer guide (English and Chinese), MIT licence

SHA-256: f010097ea0eab84375ad0b974c1eeec51b0cf98a57dd5fd96e2fcba5a73569bd

The spec files are also published individually:

What every template does

All four implement the same sample connector, a small ERP with two tenants:

Tool Access
orders.search read
orders.get read
inventory.list read
inventory.adjust write · approval

And the same behaviour:

  • Both transports. MCP on POST /mcp, REST on GET /orgrelay/manifest and POST /orgrelay/tools/{name}. One run() function serves both.
  • Tenants from tokens. CONNECTOR_TOKENS="tokenA:tenant-a,tokenB:tenant-b". Each tenant has different sample data, so the self-test can prove isolation.
  • Validation of required fields, types and enums against inputSchema, returning invalid_arguments.
  • Idempotency keyed by tenant and key, as required for write tools.
  • Error mapping from codes to HTTP status and MCP isError, as listed in the connector spec.
  • Port 8787 by default, PORT to change it.

Node.js 18+

templates/node/server.mjs, about 12 KB, no dependencies.

Function What to do with it
TOOLS Replace with your tool definitions
DATA Delete; query your database or API instead
run(tenant, name, a, idemKey) One case per tool. Filter by tenant first
validate(schema, a) Keep, or swap for a schema library such as Ajv
tenantOf(req) Replace the token map with your token store
pushEvent(url, secret, type, summary, data) Copy into the code path that creates orders or alerts. See events

Python 3.9+

templates/python/server.py, standard library only (http.server, hmac, json).

The structure mirrors Node: manifest(), validate(), run() and push_event(). For production, put it behind a WSGI or ASGI server or port run() into your existing Flask, Django or FastAPI app; the request handling is a thin layer over run().

PHP 8.1+

templates/php/server.php, runs with php -S 127.0.0.1:8787 templates/php/server.php.

PHP's built-in server starts fresh for each request, so the template keeps sample data and idempotency keys in a JSON file, guarded by flock. Set CONNECTOR_STORE to choose the file. In production, replace with_store() with your database transaction, which is also where idempotency keys belong. push_event() sends a signed event with cURL.

Java 17+

templates/java/ConnectorServer.java, one file using the JDK's built-in HttpServer. Run it directly with java templates/java/ConnectorServer.java, no build step.

It keeps MCP session ids in a set, idempotency results in a ConcurrentHashMap, and synchronises run() for simplicity. In a Spring application, move run() into a service and expose the two REST endpoints and /mcp from controllers. pushEvent() signs and sends an event with javax.crypto.Mac and the JDK's HTTP client, as described on events.

Comment language

The kit ships each template twice: templates/<language>/ has Chinese comments and messages, and templates/en/<language>/ has the same code with English comments and error messages. Pick either; they behave identically.

Verified runs

We ran the unmodified English-commented templates against the self-test for this page:

Template MCP, with --write REST, with --write
Node.js 28 pass 26 pass
Python 28 pass 26 pass
Java 28 pass 26 pass

The quickstart shows the full output.

From template to real connector

  1. Rename the connector in manifest(): four-language name, your version, vendor.
  2. Replace the tools. Use standard names where they fit.
  3. Rewrite run() against your system. Keep the tenant filter as the first line of each case.
  4. Move idempotency keys into your database.
  5. Replace the token map with real authentication.
  6. Run the self-test with --token-b and, on a test system, --write.
  7. Review the security requirements.

Licence

MIT. You can use, modify and ship the templates in commercial products. The licence text is in LICENSE inside the zip.

Common questions

Third-party packages? None. Standard library only.

Commercial use? Yes, MIT.

Why a file store in PHP? The built-in server is per-request. Use your database in production.

Next

  • Want to see the tools work in an AI client first? Add the running template to Claude Code as an MCP server.
  • If the system is an off-the-shelf platform, check the connector directory before writing code.
  • For the owner who will approve your connector's write tools, the approvals page on orgrelay.com explains their side.

Updated (Singapore time) · OrgRelay Team