Skip to content

mcp-openclaw: fix loader + align with current OpenClaw plugin API (closes #4)#5

Open
clawdreyhepburn wants to merge 1 commit into
aauth-dev:mainfrom
clawdreyhepburn:fix/openclaw-plugin-loader
Open

mcp-openclaw: fix loader + align with current OpenClaw plugin API (closes #4)#5
clawdreyhepburn wants to merge 1 commit into
aauth-dev:mainfrom
clawdreyhepburn:fix/openclaw-plugin-loader

Conversation

@clawdreyhepburn
Copy link
Copy Markdown

Closes #4.

Fixes the three issues blocking @aauth/mcp-openclaw from loading on current OpenClaw, plus the async-leaky register() that was on the way:

Discovery + activation (the blockers)

  1. package.json was missing the openclaw discovery key. OpenClaw discovers installed (non-bundled) plugins via package.json.openclaw.extensions (and optionally runtimeExtensions). Without that key the plugin is invisible and shows up as plugin not found: aauth-mcp in gateway logs. Added:

    "openclaw": {
      "extensions": ["./src/index.ts"],
      "runtimeExtensions": ["./dist/index.js"]
    }
  2. openclaw.plugin.json declared an unsupported entry field. The manifest is metadata-only by design — OpenClaw reads it before any plugin code is loaded so config validation can run without booting plugin runtime. Code entry belongs in package.json.openclaw.*. Dropped.

  3. register(api) was using a non-existent OpenClaw plugin API. The plugin called api.getConfig(), api.registerTool(name, handler), and api.onShutdown(fn) — none of those exist. Rewrote against the real OpenClawPluginApi:

    • api.pluginConfig (property, not method)
    • api.registerTool({ name, description, parameters, execute }) (object)
    • api.registerService({ id, start, stop }) for connect/disconnect lifecycle

Bonus fixes

  • register() was async-leaky. It returned synchronously and registered tools later in a .then(), so tools could miss OpenClaw's static catalog snapshot used during setup-only loading. Tools are now registered inside the service start() lifecycle, which has a deterministic completion point.
  • ServerManager.getTools() now returns description and inputSchema from MCP listTools, so the OpenClaw tool registration includes proper schemas instead of opaque {} everywhere.
  • README config example was wrong. The plugin id is aauth-mcp, not aauth, so the example as written would fail config validation against the manifest. Fixed and removed the unused delegate field from the example.
  • Silent failures now log warnings. Missing agent_url and empty mcp_servers previously failed silently; now they emit api.logger.{error,warn} so it's visible in the gateway log.

Verification

  • npm run -w @aauth/mcp-openclaw build is clean.
  • npx vitest run --root mcp-openclaw is green (6/6). The getTools test was updated to match the new return shape and now also asserts that description + inputSchema flow through.
  • I haven't tested the plugin loading on a live OpenClaw in this branch (Sarah asked me to stop poking my own gateway) — the changes were derived from reading openclaw/dist/plugin-sdk/src/plugins/types.d.ts, the published Plugin manifest and Plugin entry points docs, and a working reference plugin (@clawdreyhepburn/openclaw-ovid) installed alongside it. Happy to do a live load test once you've reviewed.

Out of scope (followups available on request)

The following were called out in #4 as contract issues but I kept them out of this PR to keep the diff focused on closing the issue:

  • Optional agent_url with auto-discovery via listConfiguredAgents()
  • Removing the delegate field from the public config schema
  • Tool prefix collision handling (<server>__<tool> or single-tool dispatch)
  • setup-entry.ts for openclaw onboard integration
  • registerAutoEnableProbe for auto-light-up after aauth-bootstrap

Happy to file separate PRs for any subset of those.


The protocol-layer packages (@aauth/local-keys, @aauth/mcp-agent) all worked beautifully end-to-end while debugging this — three-party flow against whoami.aauth.dev returned full identity claims via person.hello-beta.net on first real attempt. This PR is purely about the OpenClaw plugin entry; the rest of the stack is in great shape.

Closes aauth-dev#4.

The plugin did not load against any current OpenClaw runtime. Three
problems blocked discovery and activation:

1. package.json was missing the `openclaw` discovery key. OpenClaw
   discovers installed plugins via `package.json.openclaw.extensions`
   (or `runtimeExtensions`); without that key the plugin is invisible.

2. openclaw.plugin.json declared an `entry` field. The OpenClaw plugin
   manifest is metadata-only by design; code entry belongs in
   `package.json.openclaw.*`. The `entry` field was silently ignored.

3. `register(api)` called `api.getConfig()`, `api.registerTool(name, fn)`,
   and `api.onShutdown(fn)`. None of those exist on `OpenClawPluginApi`.
   The real API exposes `pluginConfig` (property), `registerTool({...})`
   (object), and `registerService({id, start, stop})` for lifecycle.

This PR:

- Adds `package.json.openclaw.{extensions, runtimeExtensions}` so the
  plugin is discoverable.
- Drops the unused `entry` field from openclaw.plugin.json.
- Rewrites src/index.ts against the real OpenClaw plugin API, using
  `registerService({start, stop})` for lifecycle. This also fixes the
  async-leaky `register()` (tools were previously registered after
  `register()` returned, which can miss the static catalog snapshot).
- Plumbs `description` and `inputSchema` from MCP `listTools` through
  `ServerManager.getTools()` so registered OpenClaw tools have proper
  metadata.
- Adds a clear logger warning when `agent_url` is missing or
  `mcp_servers` is empty (previously a silent no-op).
- Fixes the README config example: the plugin id is `aauth-mcp`, not
  `aauth`. Removes the unused `delegate` field from the example.
- Bumps version to 0.8.2.

Tests in `server-manager.test.ts` are updated for the new
`getTools()` shape and now also assert that tool description and
inputSchema flow through. `vitest run` is green.

Refs:
  https://docs.openclaw.ai/plugins/manifest
  https://docs.openclaw.ai/plugins/sdk-entrypoints
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[mcp-openclaw] Plugin does not load on current OpenClaw — discovery + API contract issues

1 participant