Skip to main content

Building your own application with your AI agent

In this tutorial your AI agent builds a small web application for your tenant from the public template repository: an Angular app with login, navigation and a table of the inspections you modelled in tutorial 6. The agent works MCP-first: it reads the knowledge pages of your tenant, does every step in the tenant with a tool of the OctoMesh MCP server and uses local tools only where no MCP tool can exist, for example npm on your machine. You decide and check in the browser.

The quick start shows the whole way of working in six steps; this tutorial is its step 4 (user interface) in depth.

Time: about 60 minutes, plus the one-time setup.

Requirements
  • A test tenant and a login to it, either

    • a local tenant from getting-started (OctoMesh 3.5.23 or newer, tenant meshtest, MCP server at https://mcp.127-0-0-1.nip.io/mcp), or
    • a hosted test tenant your OctoMesh administrator gives you, with the builder knowledge (blueprint System.Ai.Builder) installed.

    Your user needs the right to register clients in that tenant (tenant administrator). The tenant holds the inspection model of tutorial 6 with its sample data, or you import it in step 1.

  • An AI agent connected to the MCP server of your tenant, for example Claude Code, as described in tutorial 4. The OctoMesh skills for your agent are optional; this tutorial works without them.

  • Git, Node.js in the version of the template's .nvmrc, and for the certificate of the local dev server PowerShell 7 and openssl.

  • Your own Telerik licence for Kendo UI for Angular (a free 30-day trial is enough). The app does not build or start without it. Meshmakers does not provide a key.

Use a test tenant

The agent writes to the tenant: it registers a login client and may import a model and sample data. Never do this in a productive tenant.

What you build​

At the end the app runs on your machine at https://localhost:4300, you log in with your tenant user, and the page Inspection List shows the inspections of your tenant. Then the agent adds a second page from a one-line prompt.

Who logs in where​

Three different logins are involved. None of them needs a secret in a file.

LoginClient typeWho registers itScope
Your app in the browserAuthorization code with PKCE. A browser app cannot keep a secret, so the client has none.The agent, in step 3, with add_authorization_code_clientopenid profile octo_api offline_access: octo_api gives access to the OctoMesh APIs, offline_access keeps the session alive with a refresh token
Your AI agent at the MCP serverThe MCP client's own OAuth login, which you did once in tutorial 4Already thereEvery tool runs with your user and your roles, never with more
A service without a userClient credentialsNot needed in this tutorial-

The app reads its settings from src/<app>/src/assets/config.json; it contains URLs, the tenant and the client id, but no secret.

Step 0: Knowledge first​

Start every session with the same instruction. Tell your agent:

Read the knowledge pages of my tenant first (knowledge_search) and cite the pages you use. We build an Angular app from meshmakers/template-repo that lists the entities of the type Tutorial.Inspections/Inspection.

The agent searches with knowledge_search and opens the pages with knowledge_get. Expect it to cite pages such as app-index (how an OctoMesh app is put together), admin-clients-scopes (login clients and scopes) and admin-data-model-graphql (how the GraphQL names are derived). For the template itself there is no knowledge page; the agent then says so and works from the descriptions of the MCP tools, which it cites as [tool:<name>].

You check: the answer cites pages. If knowledge_search returns a builderKnowledgeHint, the builder knowledge is not installed in your tenant: ask a tenant administrator to install the blueprint System.Ai.Builder.

Step 1: Check the model and the data​

You say: "Is the inspection model in my tenant, and which inspections exist?"

The agent checks the models with get_available_models (or get_ck_library_status), reads the type with get_type_schema for Tutorial.Inspections/Inspection and lists the entities with query_entities.

Expected result: the type with the attributes name, inspectedAt, outcome and remarks, and at least the inspection Annual inspection 2026 of the sample data.

If the model is missing, the agent imports it over MCP:

  1. The public Basic model with import_ck_from_catalog.
  2. Your compiled model of tutorial 6 (ck-tutorial.inspections.yaml) with prepare_file_upload, a PUT of the file to the returned upload path, and import_ck_model. CLI only: compiling the model with octo-ckc (install the compiler), see tutorial 6, step 3, because the import takes compiled models only.
  3. The sample data of tutorial 6 (sample.yaml) the same way with import_runtime_model.

prepare_file_upload returns an upload path (/file-transfer/upload/<transferId>). The agent sends the file there with a PUT to the host of the MCP server without the /<tenant>/mcp path, as raw bytes with Content-Type: application/octet-stream, and then calls the import with the transfer id:

curl -X PUT -H "Content-Type: application/octet-stream" \
--data-binary @ck-tutorial.inspections.yaml \
"https://mcp.<your-domain>/file-transfer/upload/<transferId>"

The upload slot expires after about 30 minutes. The request carries no token: the transfer id in the path identifies the slot, so do not share it.

The template's tenant script

The template also contains scripts/om_initialize_tenant.ps1. It imports the Basic model, the template's own sample model and one sample item; you do not need it here, because your model comes from tutorial 6. Without options it never deletes or creates a tenant, so on a hosted tenant it only imports. Only -Recreate deletes the tenant and creates it again, and the script allows that only on a local stack (every service URL of the active octo-cli context is localhost, a loopback address or a host below 127-0-0-1.nip.io). -Recreate needs a login to the system tenant: pwsh om-login-local.ps1 -tenantId octosystem of getting-started.

Step 2: Create the app from the template​

These steps run on your machine; the agent runs them in its terminal. Local tools only: the code of your app lives in your own repository, so no MCP tool is involved.

git clone https://github.com/meshmakers/template-repo.git inspections-app
cd inspections-app
./init.sh --app-name Inspections --tenant-id <tenant> --yes
git add -A && git commit -m "Initialize the app from the template"

On a terminal init.sh asks for its values; with the options it asks nothing, so an agent can run it. --app-name is the app name in PascalCase, --tenant-id the tenant of the app (without it the tenant id is the app name in kebab case, here inspections), and --yes skips the confirmation. The default language is en-GB; --lang and --extra-langs change it. ./init.sh --help lists all options. Invalid input stops the script with exit code 2 before it changes a file.

Expected result: the script replaces the placeholders, renames src/custom-app/ to src/inspections/, removes itself and ends with "Initialization complete!". The tenant id in src/inspections/src/assets/config.json, in the Helm values and in the scripts of scripts/ is now your <tenant>, the client id inspections-frontend-debug.

Step 3: Register the login client of the app​

You say: "Register the login client for the local dev server of the app."

The agent calls, in the tenant of step 1:

  1. add_authorization_code_client with

    • clientId: inspections-frontend-debug
    • clientName: Inspections (local development)
    • clientUri: https://localhost:4300/

    The redirect, logout and CORS addresses default to the client URI, so the browser may call the tenant from the dev server.

  2. add_scope_to_client twice, with octo_api and with offline_access.

You check: get_client for inspections-frontend-debug shows the client with the redirect URI https://localhost:4300/ and both scopes. If the call fails with Forbidden, your user may not manage clients in this tenant: ask your tenant administrator for the role or to register the client.

Fallback

The template also contains the script scripts/om_setupIdentityService_local.ps1, which does the same with octo-cli. You do not need it when the MCP tools work.

Step 4: Configure the app​

You say: "Point the app at my tenant."

The agent edits src/inspections/src/assets/config.json. tenantId already holds the tenant you passed to init.sh in step 2; the agent checks it and sets the URLs:

KeyLocal tenant (getting-started)Hosted tenant
tenantIdmeshtest<tenant>
apiUrlhttps://assets.127-0-0-1.nip.iohttps://assets.<your-domain>
authorityUrlhttps://identity.127-0-0-1.nip.io/https://connect.<your-domain>/
assetServicesUrlhttps://assets.127-0-0-1.nip.iohttps://assets.<your-domain>
clientIdinspections-frontend-debuginspections-frontend-debug
scopeopenid profile octo_api offline_accessopenid profile octo_api offline_access

Your administrator tells you the domain of a hosted installation.

The dev server runs with HTTPS on port 4300 and needs a certificate. CLI only: the certificate is a local file of your machine, created by the template's script:

pwsh scripts/generate-dev-certs.ps1

With the local getting-started stack your browser must also trust the stack's root CA; om-install.ps1 installs it unless you used -SkipTrustCa.

Step 5: Scaffold the page​

You say: "Add a page Inspection List that shows the inspections in a table with name, date of the inspection, outcome and remarks."

The agent uses the scaffold tools. They plan and render the files; the agent writes them with its own file tools, because the MCP server cannot write to your machine.

  1. get_custom_app_template_manifest lists the files of the template that it may edit and the generated files it must leave alone.

  2. plan_custom_app_scaffold with appSlug inspections and drawerItems Inspection List returns the page inspection-list, its route and its drawer item.

  3. apply_custom_app_scaffold with that plan and a type binding for the route inspection-list:

    • TypeId: Tutorial.Inspections/Inspection
    • GraphqlOperationName: tutorialInspectionsInspection (the CK type id in camelCase without separators, see tutorial 2)
    • Attributes: name, inspectedAt, outcome and remarks, each with its TypeScript type; remarks is optional.

    The tool returns the page component, its template and style, a service with a unit test, a DTO, the GraphQL query getInspectionList.graphql, an edit of app.routes.ts and an edit of the drawer items.

  4. The agent fills in the grid columns (the page template only has placeholders), formats inspectedAt with the date pipe and adds the drawer icon to custom-svg-icons.ts, as the tool's NextSteps say. list_kendo_components names the Kendo component and import for anything else the page needs.

Paths after init.sh

The scaffold tools write every file below src/custom-app/, the folder name before init.sh. After init.sh your app lives in src/inspections/. Tell the agent to replace src/custom-app/ with src/inspections/ in every path the tools return, and to pass the three edit paths (appRoutesPath, commandSettingsPath, customSvgIconsPath) with src/inspections/.

You check: the diff. The query selects the attributes of the type, the route inspection-list is registered under :lang, and the drawer has the new item.

Step 6: Generate the GraphQL client​

The app talks to the tenant through typed Apollo services that npm run codegen generates from the GraphQL schema of your tenant. The schema depends on the models in the tenant, so it comes from the tenant, not from the template.

You say: "Fetch the GraphQL schema of my tenant and generate the client."

The agent:

  1. Calls export_runtime_graphql_sdl. The tool returns a download path, not the schema itself, because the schema is several megabytes large.

  2. Downloads it once (the path works once and for 30 minutes) from the MCP host, without the tenant part of the MCP address:

    curl -fsS -o src/inspections/schema.json "https://mcp.<your-domain>/file-transfer/download/<transferId>"

    With getting-started the host is https://mcp.127-0-0-1.nip.io.

  3. Runs npm install and npm run codegen in src/inspections/.

npm run codegen reads schema.json in the app folder by default, so nothing else needs to be configured. For a schema as SDL instead, the agent runs OCTO_GRAPHQL_SCHEMA=schema.graphql npm run codegen. The template's sample query is not part of npm run codegen: it needs the template's sample model, and the sample table stays off until you turn it on.

Expected result: src/app/graphQL/getInspectionList.generated.ts exists with GetInspectionListGQL.

Step 7: Check, start and log in​

Set your Telerik licence in the shell where the app is built. Never put it into a file of the repository:

export TELERIK_LICENSE='<your licence key>'
cd src/inspections
npm run lint && npm run test:ci && npm run build:prod
npm start

Expected result: lint without errors, all unit tests green (including the test of the new service), the production build completes, and the dev server runs at https://localhost:4300.

You check in the browser:

  1. Open https://localhost:4300. The app sends you to the login page of your tenant.
  2. Log in with your tenant user. You come back to the app.
  3. Open Inspection List in the drawer. The table shows Annual inspection 2026 with its date, the outcome and the remarks.
  4. Compare the rows with what the agent lists with query_entities for Tutorial.Inspections/Inspection.

Commit the result when everything is green.

Step 8: Let the agent add a page​

You say: "Add a page Assets that lists the assets of my tenant with their name."

The agent runs the same steps for one more page: plan_custom_app_scaffold with Assets, apply_custom_app_scaffold with a binding to Basic/Asset (GraphqlOperationName basicAsset, attribute name), the path replacement of step 5, npm run codegen (the schema of step 6 already contains basicAsset), then lint, tests and build.

You check in the browser: the drawer has Assets, and the page lists Boiler 1, the asset the inspection belongs to.

If your app calls an HTTP endpoint​

This tutorial reads data over GraphQL only. If your app later calls an HTTP endpoint of a pipeline (see step 3 of the quick start), two rules apply:

  • Order: the agent first creates the DataFlow and Pipeline entities with import_runtime_model (upload as in step 1), then deploys the pipeline with deploy_pipeline. In the other order deploy_pipeline fails with Pipeline '<id>' not found.
  • Reachable from outside: an HTTP route is reachable only through the ingress of the tenant's adapter, at https://<adapter-hostname>/<tenant>/<path>. The agent reads the adapter's ingressEnabled and hostname with query_entities; if the ingress is not enabled, ask your OctoMesh administrator. The route stays authenticated: the app calls it with the user's token.

Typical pitfalls​

What you seeCause and remedy
The agent answers without citing pagesRepeat the instruction of step 0. An agent that answers from general knowledge guesses.
knowledge_search returns builderKnowledgeHintThe builder knowledge is missing; a tenant administrator installs System.Ai.Builder.
add_authorization_code_client fails with ForbiddenYour user may not manage clients in the tenant. Ask the tenant administrator.
New files end up in src/custom-app/The scaffold paths still use the template folder. Replace them with src/<app>/ (step 5).
npm run codegen cannot read the schemaschema.json is missing in src/<app>/. Download it again (step 6); for an SDL file set OCTO_GRAPHQL_SCHEMA.
The download of the schema answers 404The download path works once and expires after 30 minutes. Call export_runtime_graphql_sdl again.
The upload of the model answers 404The upload goes to the MCP host without /<tenant>/mcp, as PUT with Content-Type: application/octet-stream, within about 30 minutes of prepare_file_upload (step 1).
deploy_pipeline reports Pipeline '<id>' not foundCreate the DataFlow and Pipeline entities with import_runtime_model first.
An HTTP endpoint cannot be reached from outsideThe adapter of your tenant needs an ingress; ask your OctoMesh administrator.
npm start or npm run build:prod stops right awayTELERIK_LICENSE is not set in this shell.
The login ends with a certificate errorThe browser does not trust the dev certificate or the root CA of the local stack (step 4).
The login page says the client or the redirect URI is unknownclientId in config.json and the registered client differ, or the client is registered in another tenant than tenantId.
The table stays emptyThe tenant has no inspections yet (step 1), or tenantId in config.json names another tenant.
A type error in the generated service after you changed the modelFetch the schema again (step 6) and run npm run codegen; the schema follows the model of the tenant.

Where local tools remain​

StepToolWhy there is no MCP tool
1 (only if the model is missing)octo-ckc (install), curl for the uploadThe import over MCP takes compiled models; compiling runs on your machine, and the file goes from your machine to the upload slot.
2git clone, ./init.shThe app code lives in your own repository.
4pwsh scripts/generate-dev-certs.ps1The certificate is a file of your machine.
6curl, npm install, npm run codegenThe MCP server delivers the schema; the code generator runs where the code is.
7npm run lint, npm run test:ci, npm run build:prod, npm startBuilds and the dev server run locally.

Summary​

  • The agent reads the knowledge pages first and cites them; where no page exists, it works from the tool descriptions.
  • Everything in the tenant runs over MCP with your login: checking and importing the model, registering the login client (add_authorization_code_client, add_scope_to_client), the scaffold (plan_custom_app_scaffold, apply_custom_app_scaffold) and the GraphQL schema (export_runtime_graphql_sdl).
  • Local tools remain for the code on your machine: git, init.sh, the dev certificate, npm.
  • The browser app logs in with authorization code and PKCE and needs the scopes octo_api and offline_access; no secret is stored in the app or the repository, the Telerik licence included.

Where to go next​

The next tutorial packages the app with the model into a blueprint and deploys it to a tenant; it is in preparation and will be listed in the overview.