Skip to content

feat: add add-space-from-template tool#449

Open
Tom8810 wants to merge 2 commits into
kintone:mainfrom
Tom8810:feat/add-space-from-template-tool
Open

feat: add add-space-from-template tool#449
Tom8810 wants to merge 2 commits into
kintone:mainfrom
Tom8810:feat/add-space-from-template-tool

Conversation

@Tom8810
Copy link
Copy Markdown
Contributor

@Tom8810 Tom8810 commented May 21, 2026

Why

The kintone MCP had no way to create a new space from an existing space template. Creating spaces typically requires a kintone System Administrator (or a user explicitly granted space-creation rights) and goes through the Templates REST API (POST /k/v1/template/space.json), so it is a privileged, write operation that should be exposed deliberately rather than as a general user action.

To keep the operation safe by default, this tool is disabled when using API token authentication (consistent with kintone-get-apps and kintone-add-app), since the Templates Space API does not work with API tokens.

What

  • Add kintone-add-space-from-template: takes a template id, the new space name, a members array (USER / GROUP / ORGANIZATION entities with isAdmin and includeSubs), and optional isPrivate, isGuest, fixedMember flags. Calls KintoneRestAPIClient.space.addSpaceFromTemplate and returns the newly created space id as both structured content and pretty-printed JSON text.
  • Input validation via Zod:
    • members must contain at least one entry, and at least one of them is expected to have isAdmin: true (matches the API requirement; otherwise the API rejects the request).
    • isGuest: true is only valid when the supplied template is a guest space template.
    • Optional flags default to false (isPrivate, isGuest, fixedMember, isAdmin, includeSubs).
  • Add unit tests covering tool name, description, input/output schema (including default values, required-field errors, invalid enum values), and the callback path with mocked client.
  • Update manifest.json, README.md, and README_en.md to list the new tool.
  • Extend tool-filters so kintone-add-space-from-template is excluded under API token authentication.
  • Extend the test createMockClient with a space.addSpaceFromTemplate mock hook.

How to test

  1. Prepare a kintone environment where you can create spaces from templates, with KINTONE_BASE_URL and credentials that the Templates Space API accepts (e.g., a kintone System Administrator using username/password; not API-token-only).
  2. With API token only, confirm kintone-add-space-from-template is not enabled (excluded by tool-filters).
  3. With user authentication, call kintone-add-space-from-template with:
    • a valid template id,
    • a new space name,
    • a members array containing at least one member with isAdmin: true,
    • optionally isPrivate, isGuest, fixedMember.
  4. Verify the response contains the newly created space id and that the space is visible in kintone (created immediately on the production environment; no deploy step).
  5. Verify error paths:
    • empty members array → request is rejected before calling the API,
    • no member with isAdmin: true → API rejects the request,
    • isGuest: true against a non-guest template → API rejects the request.

Checklist

  • Updated documentation if it is required.
  • Added tests if it is required.
  • Passed pnpm lint and pnpm test on the root directory.

@Tom8810 Tom8810 requested a review from a team as a code owner May 21, 2026 02:43
@Tom8810 Tom8810 requested review from chihiro-adachi and nameless-mc and removed request for a team May 21, 2026 02:43
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.

1 participant