Sitecore AI MCP Server
An MCP server for reading Sitecore XM Cloud content via GraphQL, exposing tools to get item details and list children, with OAuth authentication and path-based access control.
README
Sitecore AI MCP Server
A Model Context Protocol (MCP) server that exposes two read tools over the SitecoreAI / XM Cloud Content Management GraphQL API:
| Tool | What it does |
|---|---|
get_item_detail |
Fetch one item's full detail: id, name, path, template name, display name, all fields, children count |
list_items |
List an item's immediate children, optionally filtered by template |
It runs over stdio, so any MCP client (Claude Desktop, Claude Code, etc.) can launch it as a local subprocess. Authentication uses the OAuth 2.0 client-credentials grant, with an in-memory token manager that caches and proactively refreshes the access token before it expires.
1. Prerequisites
- Node.js 18+ (uses the built-in global
fetch). - A Sitecore XM Cloud environment (or a self-hosted CM instance) whose Content Management GraphQL API is enabled.
- An OAuth client (client id + secret) that is authorised to call that API.
2. Install & build
npm install
npm run build
This compiles src/** to dist/**. The executable entrypoint is
dist/index.js.
3. Configure environment variables
Copy the example file and fill in the values:
cp .env.example .env
| Variable | Required | Description |
|---|---|---|
SITECORE_API_URL |
✅ | Content Management GraphQL endpoint, e.g. https://<cm-host>/sitecore/api/authoring/graphql/v1 |
SITECORE_TOKEN_URL |
✅ | OAuth token endpoint (identity server), e.g. https://auth.sitecorecloud.io/oauth/token |
SITECORE_CLIENT_ID |
✅ | OAuth client id |
SITECORE_CLIENT_SECRET |
✅ | OAuth client secret |
SITECORE_SCOPE |
⬜ | OAuth scope, if your identity server requires one |
SITECORE_AUDIENCE |
⬜ | OAuth audience, if your identity server requires one |
The server never logs the client secret or the access token. Errors are surfaced with a category (
auth,forbidden,not_found,invalid_template,graphql,network,config) and a short, secret-free detail string.
Access policy (deny-by-default)
Every tool call passes through a path-based policy before any field values or children are read:
- Zero-network deny — the well-known Sitecore protected roots
(
/sitecore/system,/sitecore/templates,/sitecore/layout) have fixed, public GUIDs, so a request for one is refused with no network call at all. - Path gate — for every other id, a minimal path-only lookup runs first,
the policy decides, and only then is the item's content fetched. Anything
outside the allow-list is denied by default; a denial surfaces as a
[forbidden]tool error.
| Variable | Default | Purpose |
|---|---|---|
SITECORE_ALLOW_PATHS |
/sitecore/content,/sitecore/media library |
Readable path prefixes. Anything not matched is denied. |
SITECORE_PROTECTED_PATHS |
/sitecore/system,/sitecore/templates,/sitecore/layout |
Blocked outright unless developer mode is on. |
SITECORE_DEVELOPER_MODE |
false |
When true/1/yes/on, lifts the block on the protected areas. |
Why block templates/system/layout by default: an agent that can read — and especially, once write tools exist, edit — a template can take down every page built on it with one plausible-looking change. Keep
SITECORE_DEVELOPER_MODEoff in any environment an agent reaches unsupervised, and turn it on only for a deliberate developer session.Because the tools are keyed by item id (an opaque GUID), the id → path mapping for non-root items requires exactly one lightweight metadata lookup; the gate then runs before any content, field values, or (future) mutation is touched.
Where to generate the OAuth client id / secret
XM Cloud (Sitecore Cloud):
- Sign in to the XM Cloud Deploy / Cloud Portal.
- Open Credentials (Organization settings → Automation client credentials, or the environment's Developer settings).
- Create a new client with the scope/role needed to read content via the Authoring/Content GraphQL API.
- Copy the generated Client ID and Client Secret into
.env. - The token endpoint for Sitecore Cloud is typically
https://auth.sitecorecloud.io/oauth/token— set that asSITECORE_TOKEN_URL.
Self-hosted XM / CM instance:
- Register an OAuth client in your Sitecore Identity Server configuration
(a
ClientCredentialsgrant client) with a client id and secret. - Grant it the API resource/scope for the GraphQL endpoint.
- Use your identity server's token endpoint (e.g.
https://<cm-host>/sitecore/api/identity/tokenor the IdentityServer/connect/token) asSITECORE_TOKEN_URL.
The exact GraphQL schema differs slightly between endpoints. This server targets the XM Cloud Authoring & Management GraphQL API shape (
item(where: { itemId, language, version }),fields { nodes { name value } },children { nodes / totalCount }). If your endpoint uses a different schema, adjust the queries insrc/tools/getItemDetail.tsandsrc/tools/listItems.ts.
4. Register the server in an MCP client
Claude Desktop (claude_desktop_config.json)
Location:
- macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Windows:
%APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"sitecore-ai": {
"command": "node",
"args": ["C:\\path\\to\\SItecoreAISimpleMCP\\dist\\index.js"],
"env": {
"SITECORE_API_URL": "https://<cm-host>/sitecore/api/authoring/graphql/v1",
"SITECORE_TOKEN_URL": "https://auth.sitecorecloud.io/oauth/token",
"SITECORE_CLIENT_ID": "your-client-id",
"SITECORE_CLIENT_SECRET": "your-client-secret"
}
}
}
}
Restart Claude Desktop; the two tools appear under the 🔌 tools menu.
Claude Code
claude mcp add sitecore-ai \
--env SITECORE_API_URL=https://<cm-host>/sitecore/api/authoring/graphql/v1 \
--env SITECORE_TOKEN_URL=https://auth.sitecorecloud.io/oauth/token \
--env SITECORE_CLIENT_ID=your-client-id \
--env SITECORE_CLIENT_SECRET=your-client-secret \
-- node C:\\path\\to\\SItecoreAISimpleMCP\\dist\\index.js
5. Usage examples
get_item_detail:
{ "itemId": "110D559F-DEA5-42EA-9C1C-8A5DF7E70EF9", "language": "en" }
list_items (optionally filtered by template):
{
"parentId": "0DE95AE4-41AB-4D01-9EB0-67441B7C2450",
"language": "en",
"templateId": "76036F5E-CBCE-46D1-AF0A-4143F9B557AA"
}
GUIDs may be dashed, braced ({...}), or raw 32-hex — all forms are accepted.
6. Tests
npm test
Unit tests cover:
- Token manager — grant request shape, caching, proactive refresh before
expiry, concurrent-refresh coalescing,
invalidate(), and 401/network/config error handling (plus a check that the secret never leaks into errors). get_item_detail— field mapping, defaults, version passthrough, not-found handling, and input validation.list_items— child mapping, template filtering (GUID-form-insensitive), invalid-template detection, empty children, not-found, input validation, and policy enforcement (protected parent by id/path, per-child filtering).- Access policy — allow-list matching, protected-area blocking, deny by
default, sibling-prefix safety, developer-mode lifting the block, and
fromEnvparsing.
Both tool suites mock the GraphQL client; the token-manager suite mocks
fetch.
7. Project structure
src/
index.ts # server entrypoint, registers tools over stdio
sitecoreClient.ts # GraphQL client wrapper (adds bearer token, 401 retry)
itemPath.ts # minimal id -> path lookup used by the policy gate
policy.ts # PathPolicy: deny-by-default allow-list + protected roots
context.ts # ToolContext = { client, policy }
schemas.ts # zod input schemas
errors.ts # SitecoreError + error categories
auth/
tokenManager.ts # OAuth client-credentials fetch/cache/refresh
tools/
getItemDetail.ts # get_item_detail implementation
listItems.ts # list_items implementation
tests/
tokenManager.test.ts
policy.test.ts
getItemDetail.test.ts
listItems.test.ts
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。