Build an app with AI
An AI coding assistant such as Claude Code can build a Nimles app with you. Through the Nimles MCP server it works in your tenant as you, and with these docs it knows the API. This guide builds a small news site for a team: the posts are written in the Nimles CMS, and an app of your own shows them.
You need:
- a Nimles account with developer-beta access (the Quickstart shows how to get it);
- an AI coding assistant that speaks MCP, such as Claude Code or VS Code;
- Node.js 20 or later.
1. Get a tenant and an API client
Section titled “1. Get a tenant and an API client”-
Create a tenant in the portal under My tenants, if you have none yet. You are its Owner, and it has a resource group named Default.
-
Add the built-in post types. Open the tenant, go to CMS → Content types and choose Add the built-in post types. Every post names its type, and the app reads the posts of type
Blog. -
Create an API client for the app. In the tenant’s Developer section, choose Create API client and give it the role Reader: the app only reads. Copy the client id and the secret (it is shown once), and the tenant id.
2. Connect your assistant
Section titled “2. Connect your assistant”Add the Nimles MCP server, then sign in with your Nimles account:
claude mcp add --transport http nimles https://mcp.nimles.com/mcpIn Claude Code, run /mcp and sign in. For VS Code and other clients, see MCP. To check, ask:
Which Nimles tenants can I work in?3. Let it write the content
Section titled “3. Let it write the content”Ask your assistant for the posts, in plain language:
In my Nimles tenant <tenant name>, use the Default resource group and publish three shortblog posts for our team: welcome Ada, who starts on Monday; our new office hours; and thesummer party on 14 June.The assistant writes each post in markdown and publishes it as a CMS post of type Blog with the publish_cms_page
tool. Every call runs as you, with your role in the tenant. Ask it to list the posts to see what it made.
4. Let it write the app
Section titled “4. Let it write the app”Tell the assistant what to build and point it at the docs:
Build a small Node.js 20 app without packages that shows our Nimles blog posts as a newssite: a list at / and each post at /posts/{uniqueName}. It runs on a server and gets atoken with the client credentials grant, using NIMLES_TENANT_ID, NIMLES_CLIENT_ID andNIMLES_CLIENT_SECRET, as in https://docs.nimles.com/quickstart/. It reads the posts fromthe CMS API (https://docs.nimles.com/api/cms/). Keep the secret on the server.It writes something like this. We ran this version:
// server.mjs: a news page for your team, from the blog posts in your Nimles tenant. Node 20 or later, no packages.import { createServer } from 'node:http';
const { NIMLES_TENANT_ID: tenantId, NIMLES_CLIENT_ID: clientId, NIMLES_CLIENT_SECRET: clientSecret } = process.env;
// A token lives for an hour: keep it, and get a new one a minute before it runs out.let token;async function accessToken() { if (token && token.expires > Date.now()) return token.value; const response = await fetch(`https://auth.nimles.com/tenant/${tenantId}/connect/token`, { method: 'POST', body: new URLSearchParams({ grant_type: 'client_credentials', client_id: clientId, client_secret: clientSecret, scope: 'nimles.user', }), }); if (!response.ok) throw new Error(`token: ${response.status}`); const { access_token, expires_in } = await response.json(); token = { value: access_token, expires: Date.now() + (expires_in - 60) * 1000 }; return token.value;}
// The published blog posts, newest first.async function posts() { const response = await fetch(`https://api.nimles.com/cms/api/tenant/${tenantId}/Posts?postType=Blog`, { headers: { authorization: `Bearer ${await accessToken()}` }, }); if (!response.ok) throw new Error(`posts: ${response.status}`); const { data } = await response.json(); return data .filter((post) => post.status === 'Published') .sort((a, b) => b.publishedDate.localeCompare(a.publishedDate));}
const escape = (text = '') => text.replace(/[&<>"]/g, (c) => `&#${c.charCodeAt(0)};`);const page = (title, body) => `<!doctype html><html lang="en"><meta charset="utf-8"><meta name="viewport" content="width=device-width">` + `<title>${escape(title)}</title><body style="font-family:system-ui;max-width:40rem;margin:2rem auto;padding:0 1rem">` + `${body}</body></html>`;
createServer(async (request, response) => { try { const all = await posts(); const slug = request.url.match(/^\/posts\/([\w-]+)$/)?.[1]; const post = slug && all.find((p) => p.uniqueName === slug); if (post) { // The post's content is HTML written in your own CMS. const body = `<p><a href="/">All news</a></p><h1>${escape(post.title)}</h1>${post.content}`; response.writeHead(200, { 'content-type': 'text/html; charset=utf-8' }).end(page(post.title, body)); } else if (request.url === '/') { const list = all.map((p) => `<h2><a href="/posts/${p.uniqueName}">${escape(p.title)}</a></h2><p>${escape(p.summary)}</p>`); response.writeHead(200, { 'content-type': 'text/html; charset=utf-8' }).end(page('News', `<h1>News</h1>${list.join('')}`)); } else { response.writeHead(404, { 'content-type': 'text/html; charset=utf-8' }).end(page('Not found', '<h1>Not found</h1>')); } } catch (error) { console.error(error); response.writeHead(502).end('Nimles did not answer'); }}).listen(3000, () => console.log('http://localhost:3000'));What to look for in what your assistant writes:
- The secret stays on the server. The API does not answer cross-origin browser calls (API conventions), and an API client acts with its role in your whole tenant.
- One token for an hour. Getting a new token for every request works, but is slow; keep it until it is about to expire.
- Published posts only. The list holds drafts too;
statustells them apart.
5. Run it
Section titled “5. Run it”export NIMLES_TENANT_ID='<tenant id>'export NIMLES_CLIENT_ID='<client id>'export NIMLES_CLIENT_SECRET='<secret>'node server.mjs$env:NIMLES_TENANT_ID = '<tenant id>'$env:NIMLES_CLIENT_ID = '<client id>'$env:NIMLES_CLIENT_SECRET = '<secret>'node server.mjsOpen http://localhost:3000. Ask the assistant for a new post, and it is on the site at the next reload.
To put the app online, run it on any host with Node.js 20, such as a container or an app service, and set the three variables as secrets there.
Take it further
Section titled “Take it further”Ask your assistant for the next step, and point it at the reference of the service it needs:
- A contact form whose answers are saved as form submissions in CRM.
- Pages of posts with paged, filtered reads over GraphQL instead of one list.
- Writing posts in the app, with an API client with the role Contributor and changes as JSON Patch (API conventions).
- Products and orders, files, work items or anything else among the services in the sidebar: every one follows the same URL scheme, token and conventions.