CORE Bot Developer Guide

How SegPro CORE exposes its tools to bots over MCP, how to point GrokBot at the sandbox to test the 77 tools that exist today, and how to propose the new tools you want built.

SegPro Solutions · Last updated November 16, 2026

1. Quick start

MCP endpoint (sandbox)
https://strong-elegance-sandbox.up.railway.app/api/core/mcp
Transport
MCP Streamable HTTP, stateless: every request is a single POST; no sessions to keep
Authentication
Header X-Api-Key: <your key>
Your API key
Issued by an admin: Bots → Manage → Issue key, environment sandbox, made on the production site (see section 10). It is shown once.
Your bot
A bot account an admin creates for you. For building new tools, set its Tools to All tools, including ones added later.
Works on
Sandbox only. The same key is rejected by production by design.
Keep the key privateDon't commit it to a repo or paste it in a shared channel. Anyone with it can act as your bot on sandbox. If it leaks, tell Bruce; he can revoke it instantly and issue a new one.

Smoke test from a terminal

KEY=''
URL='https://strong-elegance-sandbox.up.railway.app/api/core/mcp'

# List the tools your bot can see (expect 16 today, or 7 for a prospect-only bot)
curl -s "$URL" -H "X-Api-Key: $KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list","params":{}}'

# Call a read-only tool
curl -s "$URL" -H "X-Api-Key: $KEY" -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"list_recently_completed_projects","arguments":{"sinceMinutes":1440,"context":{"bot":"Andy","trigger":"manual test"}}}}'

Responses come back as a server-sent event (data: {...}) containing a JSON-RPC result. A tool's output is in result.content[0].text (JSON text); a tool-level failure has result.isError: true and a plain-English message the model can act on.

2. How the system works

Request flow

1. GrokBotPOSTs a JSON-RPC tools/call to /api/core/mcp with your key.
2. Key checkCORE hashes the key and finds your bot account. Wrong environment, revoked or turned-off bot: 401. If the key isn't in X-Api-Key at all (sent as Authorization: Bearer, in the URL, an empty header from an unset variable, or wrapped in quotes), the 401 says exactly that.
3. Tool accessCORE builds an MCP server with only the tools your bot is allowed (you: all).
4. Tool runsEach tool calls CORE's own REST routes as your bot, with a short-lived token.
5. LoggedInputs, result, errors and duration go to Bots → Activity; data changes go to the Audit Log.

Because tools go through CORE's normal routes, your bot is treated like a person with the BOT role: the same validation, permission checks, project locks ("someone is editing this project"), conflict checks and audit trail apply. The BOT role can view and edit Pre-Core records and view and edit CORE projects. It has no admin rights and can't reopen completed studies.

Sandbox vs production

  • Sandbox is a full copy of the production database, refreshed when Bruce runs a clone. It's real-looking data, safe to experiment on, and everything you create there is erased at the next clone.
  • Your bot, key and tool access are stored on production, tagged for sandbox, so they come back after every clone. Changes made on sandbox (by you or Bruce) don't survive a clone; ask Bruce for anything that should last.
  • Your key only works on sandbox. Production rejects it and logs it as a bad-key attempt.
  • Code is separate from data. New tools are built on a branch and deployed to sandbox (the sandbox branch auto-deploys); a clone doesn't remove them. They reach production only when Bruce merges.

Your bot's access

Each bot has a tool list set by an admin (Bots → Manage → Tools). Yours is "All tools, including ones added later", so any new tool deployed to sandbox appears for you right away, with no setup. Other bots (such as Zack's Office Bot) only get the tools ticked for them, so your new tools stay hidden from them until Bruce enables them.

After a new tool is deployedGrokBot caches the tool list when it connects. Reconnect or refresh the CORE connector to see new tools.

3. Connecting GrokBot

Add CORE as a remote MCP server (Streamable HTTP) with a custom header. The exact screen depends on your GrokBot setup; the values are:

{
  "mcpServers": {
    "segpro-core-sandbox": {
      "type": "http",
      "url": "https://strong-elegance-sandbox.up.railway.app/api/core/mcp",
      "headers": { "X-Api-Key": "" }
    }
  }
}
  • No OAuth, no session: each request stands alone. GET and DELETE on the endpoint return 405 (there are no server-initiated streams).
  • Keep this as a separate connector from any production CORE connector your other bots use, so test calls never go to production.
  • Name the connector clearly (e.g. "CORE sandbox") so the model and your prompts can tell them apart.

4. The context field (please always send it)

Every tool accepts an optional context argument. It doesn't change what the tool does; it labels the call in CORE's Bots → Activity log, so Bruce can see which bot did what and why.

"context": {
  "bot": "QC Bot",              // which bot is calling (≤ 60 chars)
  "trigger": "Slack #qc",       // what started it: "Slack #channel", "webhook: QC2 Completed", "schedule: <routine>"
  "requester": "Bruce Kowallis",// the person who asked, if any (≤ 100)
  "slackUser": "U04ABC123",     // Slack user ID/handle, if it came from Slack (≤ 100)
  "requestId": 42               // the request this call is for (see Tracking requests below)
}

All keys are optional. Unknown keys are ignored, and a malformed context never fails the call; it just isn't recorded.

Tracking requests (the Bot Activity page)

Everyone at SegPro can open Bot Activity from the apps page to see what they asked a bot for and where it stands. CORE only knows about a request once your bot records it, so a bot that takes requests from people (in Slack, by email, ...) should do this for every one:

  1. As soon as the request arrives, before doing any work, call open_bot_request with a plain-words summary (“EOB for 123 Oak St, Provo”), the type (eob, zoho_deal, onboard, report or other), source (slack, email or other), the channel, and who asked: requesterName and, whenever you can, requesterEmail. The email is what puts it under that person's Mine view. Pass the Slack message ts or email Message-ID as externalRef: calling again with the same one returns the same request, so a retry never makes a duplicate.
  2. On every tool call you make for it, send context.requestId with the id you got back. Those calls then appear on the request's timeline in plain words (“Created the Pre-Core record”, “Prepared the EOB PDF”). CORE adds the real Zoho Deal outcome and report downloads for the record on its own.
  3. Move it along with update_bot_request: working when you start, waiting when you're blocked (say on what in note), and always end with done (what you delivered and where), failed (why, in words the person can act on) or declined (you won't do it, and why). Set precoreId / projectId once you know the record.

The page flags a request that is still received or working with no update for 2 hours, so the person knows to ask. Only the bot account that opened a request can update it. The page never shows tool inputs or results; the note is what the person reads, so write it for them.

// Someone in #estimates: "Can I get an EOB for 123 Oak St, Provo?"
open_bot_request   { summary: "EOB for 123 Oak St, Provo", type: "eob", source: "slack",
                     channel: "#estimates", requesterName: "Andy Smith",
                     requesterEmail: "andy@segprosolutions.com", externalRef: "1731790000.123456" }
                   → { requestId: 42 }
update_bot_request { requestId: 42, status: "working" }
search_precore_records { query: "123 Oak", context: { requestId: 42 } }
get_precore_eob_link   { eobIds: [2781], context: { requestId: 42 } }
update_bot_request { requestId: 42, status: "done", precoreId: 2781,
                     note: "EOB posted in #estimates" }

5. The 77 current tools

Read tools only look. Write tools change sandbox data (or, where noted, something outside CORE). IDs: a project id is a CORE project (core_projects.id); a Pre-Core / EOB id is an intake record (ZacksEobIntakeForm.ID); a prospect id is a mailer prospect (ProspectEstimates.id), a separate number from Pre-Core ids.

The prospect switch. create_precore_record, update_precore_record, get_precore_record and get_precore_eob_link take an optional destination: 'prospect'. With it, the record is a mailer prospect: the same fields and validation as Pre-Core plus prospect fields (in prospect), saved to ProspectEstimates, never to Pre-Core, Zoho or CORE. The same source + sourceId again updates that prospect. For a prospect, get_precore_eob_link gives the mailer card instead of the EOB letter (same numbers); with saveToDrive: true it saves each card to Google Drive in _Prospect Mailers/<batch name>/, creating the batch folder the first time.

ToolTypeInputsWhat it does
search_projectsReadquery (≥ 2 chars)Find CORE projects by name, client or address (incl. completed). Returns up to 25: id, name, status, study type, Pre-Core id, address.
get_precore_recordReadidRead one Pre-Core intake record.
search_precore_recordsReadquery (one term)Find Pre-Core records by client, entity, email, street, city, state or ZIP. Search one term at a time and narrow yourself.
create_precore_recordWritefields (object)Create a Pre-Core record, validated like the Pre-Core form (required fields are listed in the tool's description). Refuses a duplicate street address. Returns the new id.
update_precore_recordWriteid, fieldsChange only the fields sent; everything else is kept.
onboard_precore_to_coreWriteeobIdCreate the CORE project (and first asset) from a Pre-Core record. Safe to repeat: returns the existing project if there is one.
create_zoho_dealWriteidCreate the Zoho CRM Deal for a Pre-Core record (runs in the background; poll get_precore_record for ZohoCRMDealID). See the warning below.
add_project_chat_messageWriteprojectId, message (≤ 4000)Post to a project's Chat. @FirstName mentions email that person.
get_core_report_linkReadprojectId, format pdf|excel, optional includeDepSchedule, showLandValue, showAdjDepDownload link for the final cost segregation report. Link works 15 minutes with no login; generating can take a minute or two when opened.
get_depreciation_schedule_linkReadprojectId, format excel|pngDownload link for the per-asset depreciation schedules (needs placed-in-service dates).
list_recently_completed_projectsReadoptional sinceMinutes (1–1440, default 30)Projects marked complete in the window, newest first. Track (id, completedAt) pairs: a reopened and re-completed project appears again.
get_precore_eob_linkReadeobIds (1–50), optional includeDetailsDownload link for the EOB letter PDF: one id is a single-property letter, several ids one combined letter.
create_prospect_batchWriterows [{ fields, prospect }] (up to 200)Save a batch of mailer prospects (e.g. one xlsx run). Core numbers it (“Batch #N - yyyy-MM-dd HH:mm”) and saves each row like create_precore_record with destination: 'prospect'. Returns the batch name and each row's id or problems; one bad row doesn't stop the rest.
update_prospectWriteid, fieldsA prospect's mailing, note, Handwrytten, printing, follow-up and status fields. Refuses estimate fields (those go through update_precore_record with the switch, so the numbers recalculate). Core never calls Handwrytten: write the order back here.
list_prospectsReadoptional batch, status, mailAddressNorm, limitProspects newest first, with status, batch, mailing details, Handwrytten status, mailed date and the card's Drive link. mailAddressNorm finds an owner mailed before (e.g. in the last 6 months).
query_databaseReadsqlOne read-only SELECT (max 200 rows) through a separate read-only login. The tool description includes schema notes; some tables (users, keys, settings, audit) are deliberately unreadable.
open_bot_requestWritesummary, optional type, source, channel, requesterName, requesterEmail, slackUser, externalRef, precoreId, projectIdRecord a request a person asked you for, so they can follow it on the Bot Activity page. Returns requestId; the same externalRef again returns the same request. See Tracking requests.
update_bot_requestWriterequestId, status, optional note, precoreId, projectIdMove a request along: working, waiting, done, failed or declined, with a note the person reads. Only the bot account that opened it can update it.

Engineering tools (Core Bot Toolbox, Phase 1)

For the engineering bots: everything an engineer reads in a study, plus the Documents, Images and chat work. Every tool takes projectId (so calls are logged against the project). They write through CORE's own routes as the bot, so the same rules apply as for a person: a write on a project an engineer has open returns "someone is editing" (try later, don't retry at once); completed studies are read-only. Drive scope: link_document, link_drive_images and list_drive_folder's subfolderId only accept items inside the project's Drive folder, or inside its Pre-Core folder when that is a different one (not the folders themselves). list_documents → driveFolder shows which folder the project uses, where it came from, and any other projects pointing at the same one. Takeoff, asset and square-foot writes are Phase 2 (below). New tools start off for bots with a chosen tool list: tick them in Bots → Manage → Tools.

ToolTypeInputsWhat it does
get_projectReadprojectIdProject fields, assets, subassets, square-foot models, team, tags and each asset/subasset's takeoff version, in one read.
list_usersReadActive CORE users, for @mentions.
get_project_teamReadprojectIdAssigned users, role assignments and the sales rep.
list_assets · get_asset · list_subassetsReadprojectId, assetIdAssets and subassets.
get_sqft_modelReadprojectId, assetIdAn asset's square-foot model.
search_catalogReadprojectId, optional query, group, takeoffCategory, assetId or propertyType (R/C), preferredOnly, limitThe catalog this project uses (its frozen snapshot when completed). preferred: true marks the group's default line for R or C (the catalog's R*/C* tag); relatedItems lists child lines CORE adds automatically.
get_price_historyReadprojectId, lineNumberRecent price changes for one line.
get_uniformat_csi_mapReadUniformat ↔ CSI mapping.
get_takeoffReadprojectId, assetId, optional subassetIdEach asset/subasset node with its version and its lines (catalog / actual_cost / csi), plus removed or overridden Related items. An actual-cost line with a split carries split = { mode, items (each with its index, in the shape put_takeoff takes), remainderLife / remainderCsiDivision / remainderMacrs, allocation (dollars by life) }, so a split someone wrote can be read, changed and sent back; an SC line limited to some direct lines carries indirectTargets. The raw estimates and indirectAllocations rows are still returned.
get_pricing_update_previewReadprojectIdCatalog price changes since a frozen study's snapshot.
list_documentsReadprojectIdThe Documents checklist: rows with status dates, linked files, comments, verification status and verificationMessage (why a file couldn't be read), open exceptions, and per row confirmedInputs / waitingInputs; ad-hoc rows; inputs with their source; driveFolder.
list_drive_folderReadprojectId, optional subfolderId, recursive, search, mimeType (image/ = any image), pageSize (100, max 500), pageTokenFiles and subfolders in the project's Drive folder, each with path (e.g. Photos/Online Photos/…), mimeType, modifiedTime and size. Paged: pass back nextPageToken.
list_imagesReadprojectIdImages tab: Drive and uploaded images (source + id).
get_project_chatReadprojectId, optional limitProject chat, newest first.
list_my_mentionsReadoptional includeResolvedMessages that @mention this bot.
get_activity · get_transaction_logReadprojectIdActivity feed; field-level change history.
get_document_changesReadoptional sinceMinutes (60, max 10080), projectIdWhat changed on Documents checklists across projects, newest first: received / notes / touches, rows whose links, schedule or status changed, verification runs (with message), exceptions opened or resolved. New Drive files aren't included (use list_drive_folder's modifiedTime).
get_comparable_studiesReadproperty type, study type, sq ft, city, state, basis, limit, includeStatsComparable completed studies for range checks.
link_documentWriteprojectId, documentId or adhocId, fileIds, optional mode, status, waitForVerificationLink Drive files and/or folders to a document row. mode: add (default) keeps what's already linked; remove unlinks just these; replace sets exactly this list ([] unlinks all). status (received_best / received_acceptable) marks the row received in the same call. waitForVerification waits up to a minute for CORE to read the files and returns its result (status, message, open exceptions). Returns the row's resulting links plus what was added/removed.
set_document_statusWriteprojectId, documentId, status, optional reasonreceived_best, received_acceptable, pending (clears received/waived and the inputs it confirmed) or waived. received_* on a row with no linked file is refused unless you give a reason (kept as a comment on the row).
add_document · remove_documentWriteprojectId, name / adhocIdAdd or remove an ad-hoc document row.
comment_documentWriteprojectId, documentId or adhocId, noteComment on a document row.
set_document_inputWriteprojectId, inputKey, action, …set_source (a received document's code + optional pageRef), clear_source, manual (note), waive (reason), note.
auto_link_photos · complete_inspectionWriteprojectId, documentIdLink the Drive "Photos" folder; mark the site inspection complete.
set_inspectionWriteprojectId, optional documentId, mode, scheduledDate, scheduledTime, inspectorUserId or inspector, note, clearSchedule, reschedule or clear the site inspection (the row is found when documentId is left out). mode: onsite, virtual, photos (no date), outsourced. A date needs the inspector (user id, or a CORE user's name or email; a reschedule keeps the current one). clear: true removes date, time and inspector. Logged to the project chat.
verify_documentWriteprojectId, documentId, optional waitRead a received row's linked files again and re-check the inputs (after a fix, or after an error). Waits up to a minute and returns status, message and open exceptions.
resolve_exceptionWriteprojectId, exceptionId, action, note, correctedValueResolve an open exception from list_documents. Actions by type: mismatch → use_document / keep_core (note); blank → accept; conflict → keep_authoritative / use_new (note); unreadable → confirm_manual / value_wrong (correctedValue). Logged on the row and in chat.
set_project_drive_folderWriteprojectId, folderId (ID or URL; null clears), reasonPoint the project at its own Drive folder, e.g. when several projects share one. Clearing falls back to the Pre-Core folder. Logged.
link_drive_imagesWriteprojectId, fileIdsAdd Drive images (inside the project folder) to the Images tab; images already there are skipped.
remove_images · reorder_images · set_cover_imageWriteprojectId, images (source + id)Remove from the tab (Drive files stay), set the order, set the cover.
edit_chat_message · pin_chat_messageWriteprojectId, messageIdEdit the bot's own message; pin a message.
resolve_mentionWritementionIdMark one of the bot's mentions resolved.

Building the study (Core Bot Toolbox, Phase 2)

Project, asset, subasset, square-foot model and takeoff writes. The same rules as Phase 1 apply (project lock → "someone is editing", completed studies read-only, every change recorded under the bot's name), plus:

  • Only what you send changes. CORE's own update routes replace the whole record, so these tools read it first and write back your fields on top; anything you leave out is kept. If someone changed the record in between, you get a 409: read again and re-apply.
  • Takeoffs merge by line number + life. put_takeoff needs expectedVersion (from get_takeoff; 409 if someone saved in between). Lines you don't send are left alone; replace: true also removes this bot's own earlier lines. A bot never changes or removes a line an engineer entered (ENGINEER_LINE / NOT_YOURS).
  • CORE picks the line. Send group (+ attributes such as fuel, size, material, fixture count, finish grade) instead of lineNumber, and CORE uses the group's preferred line for the asset's property type (a dwelling (single-family, townhouse, residential condo, multi-family) is residential even at 39 years, e.g. a short-term rental; otherwise 27.5-year = residential), or the allowed alternative your attributes match. The list lives in Settings → Preferred Lines; a group with no entry uses the catalog's R*/C* tag. A non-preferred line needs an altReason until the group's alternatives are loaded; after that, only matching attributes are accepted (NON_PREFERRED_WITHOUT_REASON).
  • Every line is checked before anything is saved: in the project's catalog (its snapshot when frozen), for this property type, the unit (SF / EA / LF, written any common way), a life its asset classes allow (give life only when there's more than one; 00.3 lines default to 15-year), the preferred rule, and ranges (deprFactor 0–1, adjustmentPct 0–100). Any failure → 422 with every problem listed, nothing saved. Run preview_takeoff first: same checks, plus the Related lines CORE will add and a raw cost per line.
  • Related lines are automatic. Don't send the lines CORE adds under a parent (you'll get a warning; use extraQuantity for anything on top). dismissRelated, restoreRelated and overrideRelated do what the Takeoffs tab's remove / restore / unlock do.
  • Say why. method (count, house-trend, plans, rule-of-thumb, ranges, receipt), evidence, ruleIds and note are stored with the line and shown to engineers on the line's "Bot" chip. Bot lines can be filtered with Bot Lines Only on the Takeoffs tab and in QC Review.
  • Deletes: a bot can delete only assets and subassets it created itself.
ToolTypeInputsWhat it does
resolve_componentReadprojectId, assetId, group, optional attributesThe line CORE would use, why (preferred or alternative), the allowed alternatives and the group's other lines.
preview_takeoffReadsame as put_takeoffDry run: every check, the lines as they would be saved, Related lines added/changed/removed, raw cost per line. Saves nothing. Also works on a completed study (the result says completedStudy: true), so the bots can be benchmarked on finished work against get_nc_summary; import_actual_costs with dryRun works there too. Every real write to a completed study is still refused.
put_takeoffWriteprojectId, assetId, optional subassetId, expectedVersion, components, receipts, removeLines, replace, dismissRelated / restoreRelated / overrideRelatedWrite takeoff lines to one node. Components: lineNumber or group + attributes, quantity, optional unit, life, extraQuantity, deprFactor, adjustmentPct, altReason, method, evidence, ruleIds, note. Receipts are owner invoices entered as actual-cost lines (division, name, amount, life, optional csiDivision). Returns the new version.
put_takeoff: costLinesWrite[{ name (or lineNumber of an existing ACT| line), life 5 · 7 · 15 · QIP · the asset's long life (27.5, 39, or 30 / 40 on ADS; LL means it) · MX · SC, amount (negative = a credit), optional adjustmentPct, csiDivision, costSource, split, indirectTargets, moveToLife, rename, macrs, isQip, splitItemEdits, splitLater, newLine, onEngineerLines, method / evidence / note }]New Construction / Improvement studies (their schedules use actual costs only, so catalog components are refused there with NOT_FOR_STUDY_TYPE). split = { mode, items [{ name or catalog lineNumber, life, quantity + unitCost (squeeze / deduct) or pct, optional csiDivision, adjustmentPct }], remainderLife, remainderCsiDivision }, the estimate window's three tabs: squeeze scales the items so they add up to the line exactly; deduct keeps them at cost and leaves the rest as a remainder (refused with DEDUCT_TOO_BIG when they're more than the line); pct gives each a share. A mixed-life (MX) line needs a split; split: null removes one. An SC line is spread over all direct lines, or only indirectTargets (by lineNumber + life, or name + life of a line in the same call). A mixed-life (MX) line can be a target: its share of the soft cost follows its split, part by part, exactly as the schedules spread it. The result's splits shows each breakdown's dollars by life, and when the line gets part of an indirect spread, indirectDollars plus each part's indirect and total; get_takeoff shows the same, and indirectShare on every direct line that gets one. On an existing line: moveToLife moves it like the Takeoffs tab's right-click Move (its split and indirect references go with it; a move to SC drops its split and takes it out of other indirects' spreads), rename renames it, macrs (57.0, 57.1, 79.0, 00.11, 00.12, 00.3, Sec 1250) moves it to that code's life and tags it "Reclassified" like Bulk Edit (null clears the tag; not on SC or MX lines, where split items take macrs and the split takes remainderMacrs), isQip sets the per-line QIP flag (counts once the project has QIP on). splitLater lets a new MX line in without a split for an engineer to break down. The line keeps its row, so its history stays with it. splitItemEdits changes part of an existing split instead of resending it: { index, …fields } changes that item (a life on its own replaces its MACRS code), { index, remove: true } drops it, { add: item } adds one; indexes are get_takeoff's, the mode and remainder stay, and every split check runs on the result (BAD_INDEX, NO_SPLIT when the line has none, not together with split).
put_takeoff: csiLinesWrite[{ name, unit, unitCost, quantity, life 5 · 7 · 15 · 27.5 / 39 (LL) or macrs, optional category, code, csiDivision, costSource, adjustmentPct, isQip, method / evidence / altReason / note } or { lineNumber of this bot's CSI| line + life, the fields to change, moveToLife }]PPA studies: custom CSI lines, the Takeoffs tab's "+ → CSI Item", for items no catalog line covers. Cost = quantity × unit cost, then location factor, indirects, depreciation and the squeeze like a catalog line. category is the Takeoffs table it sits under (default: the CSI division's name, or "Custom CSI"); code defaults to "CSI"; | _ ' " \ in names become -. Changing code, name, unit, unit cost or category re-keys the line (KEY_EXISTS if that line is already there). A bot changes only its own CSI lines (ENGINEER_LINE; lineEdits can still re-tag an engineer's). On New Construction / Improvement: NOT_FOR_STUDY_TYPE (use costLines and split items).
put_takeoff: lineEditsWrite[{ lineNumber, life, csiDivision, remainderLife, remainderCsiDivision, remainderMacrs, adjustmentPct, moveToLife, rename, macrs, isQip, onEngineerLines, note }]Change a line already on the node: re-tag an actual-cost line's CSI division ("26", "26 Electrical") or mark it "Excluded" (left out of every total), change a deduct / pct split's remainder life or CSI. Catalog lines take their CSI division from the catalog (STATIC_CSI); to leave one out, remove it or set adjustmentPct 0. Engineers' lines (New Construction / Improvement): a bot changes a line an engineer entered only with onEngineerLines: true, in costLines or lineEdits. The line stays the engineer's, so removeLines and replace can never delete it; the change and the bot's note are logged on the line, the Takeoffs tab shows a Bot edited chip, and the result lists it under engineerLinesEdited. Without the flag: ENGINEER_LINE.
update_projectWriteprojectId + fieldsName, entity, client, address, project type, sq ft, study type, depreciation system, purchase price, basis, land value / %, tax year, description, notes, QIP.
upsert_assetWriteprojectId, optional assetId + fieldsCreate an asset (no assetId) or change one: label, name, property type, sq ft, placed-in-service and contract dates, recovery period, bonus, basis, stories, order. bonusPct: 'auto' computes the bonus from the placed-in-service and contract dates the way the asset form does. On a New Construction / Improvement study, a new recovery period also moves the asset's long-life cost lines (and split items and remainders on that life) to it, as the asset form does; the result says how many moved.
set_asset_factorsWriteprojectId, assetId + factorsDepreciation, historic/location, owner and contractor indirects, adjustment.
upsert_subassetWriteprojectId, assetId, optional subassetId + fieldsCreate or change a subasset: label, name, unit quantity, sq ft, order.
delete_asset · delete_subassetWriteprojectId, assetId (+ subassetId)Only ones this bot created.
set_sqft_modelWriteprojectId, assetId, lines [{ code or name, keep, adjustmentPct, deprFactor, note }]Change lines of an existing square-foot model: keep: false takes a line out of the totals; above 100% needs a note explaining the count correction. Changed lines are marked as the bot's.
import_sqft_modelWriteprojectId, assetId, fileName (.xlsx / .xls), fileBase64 (up to about 7 MB)Import a square-foot model workbook onto an asset, exactly like the SqFt Model tab's Import button: lines tagged from the Uniformat → CSI map, duplicate code + name lines merged, every quantity set to the asset's square footage (set squareFootage first). Replaces the asset's model. Returns the line count and any lines left untagged.
import_actual_costsWriteprojectId, assetId, optional subassetId; fileName + fileBase64, or driveFileId; mode add (default) or replace; dryRunNew Construction / Improvement: import an actual-cost workbook (CORE's actual-cost template) like the Takeoffs tab's Upload. Data from row 4: A description, B cost, C class life (Indirect, 5 yr, 7 yr, 15 yr, QIP, Long Life, Mixed), D an optional MACRS code that wins over C. Mixed rows come in without a split. replace first removes this bot's earlier cost lines on the node; engineers' lines always stay. Returns rows imported, rows skipped with the reason (fix and re-send them), dollars by life, and the basis check from get_nc_summary.
get_nc_summaryReadprojectIdNew Construction / Improvement: what the schedules and report will show, without building them. Dollars and % by life after adjustment %, splits and the indirect spread (project and per asset / subasset), dollars by MACRS asset class, each indirect line with its % of basis and what it's spread over, and the checks to clear before QC: actual costs vs. depreciable basis, Excluded dollars, lines with no CSI division, mixed-life lines with no split.
delete_sqft_modelWriteprojectId, assetIdDelete an asset's whole model. Off unless ticked.
apply_pricing_updates · clear_snapshotWriteprojectId, optional lineItemIdsOn a study pinned to a frozen catalog: apply today's prices to some or all lines, or release the snapshot entirely. Off unless ticked.
create_projectWriteprojectName, optional precoreId, studyType (PPA default, New Construction (or NC), Improvement), address, project type, sq ft, prices, tax year, fee, descriptionCreate a project as CORE's own save does: the project-created notifications fire, and with precoreId the linked Zoho deal gets the new project id (so on sandbox, leave precoreId out unless Bruce says otherwise). Add assets with upsert_asset.
clone_projectWriteprojectId, newProjectName, optional keepOriginalPricingCORE's Duplicate: project, assets, subassets, square-foot models, takeoffs, images and Documents tab (not chat or the activity log). Keeps the source's frozen prices in its own snapshot unless keepOriginalPricing: false.
submit_to_qc1WriteprojectIdSubmit to QC (In Progress → QC1). Refused with the Documents tab's readiness reasons when it isn't ready. Fires the QC1 notification.
Two tools reach outside sandbox: ask Bruce before using them create_zoho_deal creates a Deal in Zoho CRM, which isn't a copy, and it can't be undone. Don't call it in testing unless Bruce has confirmed which Zoho environment sandbox talks to.
add_project_chat_message sends real emails to anyone you @mention. Sandbox people are real people, so test messages without @mentions.

6. Test script for GrokBot

Feed these prompts one at a time. Each one should make GrokBot pick a specific tool. Check the answer, and ask Bruce to look at Bots → Activity on sandbox to confirm the call and your context label.

Read-only (safe to run any time)

  1. "Using CORE sandbox, list the projects completed in the last 24 hours." → list_recently_completed_projects (sinceMinutes 1440)
  2. "Find the CORE project for <a client name from step 1>." → search_projects
  3. "Search Pre-Core for records with 'Oak' in the address." → search_precore_records
  4. "Show me Pre-Core record <id from step 3>." → get_precore_record
  5. "Get me the PDF report for project <id from step 2>, with the depreciation schedule." → get_core_report_link. Open the link within 15 minutes.
  6. "Get the depreciation schedules for project <id> as Excel." → get_depreciation_schedule_link
  7. "Get the EOB letter for Pre-Core record <id>." → get_precore_eob_link
  8. "How many CORE projects were completed this month, by study type?" → query_database

Writes (sandbox data only; erased at the next clone)

  1. "Create a Pre-Core record for client 'Test Andy', email test-andy@example.com, entity 'Andy Test LLC', 100 Test St, Salt Lake City UT 84101, PPA, multifamily, 39-year, tax year 2026, land 10000 sf, building 20000 sf, fee 5000, in service 01/15/2026, contract 01/01/2026, purchase price 2,000,000, land 20%." → create_precore_record. If it reports missing fields, that's the validation working; let GrokBot fill them.
  2. "Change the study fee on that record to 5500." → update_precore_record
  3. "Onboard that record into CORE." → onboard_precore_to_core (run it twice; the second call should return the same project)
  4. "Post 'Bot test, please ignore' to that project's chat." → add_project_chat_message (no @mentions)

Error handling worth checking

  • A project id that doesn't exist gives a clear "not found" message, not a crash.
  • An unknown tool name gives "Tool … not found". A tool your bot isn't allowed looks the same, and is logged in Activity.
  • More than 60 requests a minute gives a rate-limit error; GrokBot should back off rather than retry instantly.
  • A project someone has open in CORE: write tools answer "someone is editing this project right now"; try later.

7. Webhooks (optional)

CORE can notify a bot when something happens. Today there's one per-bot event, project.completed, sent when a project whose Project Coordinator owns the bot is marked complete. Bruce can add a sandbox routine pointing at your test endpoint (https only).

POST <your url>
Content-Type: application/json
X-Core-Timestamp: 1791576749            (unix seconds)
X-Core-Signature: sha256=<hex>          (if a signing secret is set)
Authorization: Bearer <token>           (if an auth header is set)

{
  "event": "project.completed",
  "environment": "sandbox",
  "projectId": 875,
  "projectName": "Alicia Hatch - 1733 39th Ave",
  "entityName": "Alicia Hatch",
  "studyType": "PPA",
  "completedAt": "2026-10-09T22:10:18.237Z",
  "completedBy": "…"
}

Verify the signature as HMAC-SHA256(secret, "<X-Core-Timestamp>.<raw body>") and reject stale timestamps. A failed delivery is retried 3 times (after 1, 5 and 25 seconds). Use list_recently_completed_projects as a backstop for any notice you miss.

chat.message (the engineering bot's runner)

When a person's project chat message contains @Engineering (any case, a space after the @ is fine), production CORE posts it to RUNNER_URL + "/chat", signed the same way with ENG_CHAT_WEBHOOK_SECRET. It's sent only when APP_ENV is production and both settings are present. Messages posted by any BOT user never trigger it, since bot replies come back through add_project_chat_message and often quote @Engineering confirm.

{
  "event": "chat.message",
  "environment": "production",
  "projectId": 875,
  "messageId": 12345,
  "text": "@Engineering what is first-year on this study?",
  "user": { "id": 3, "name": "Bruce Kowallis", "role": "admin" },
  "sentAt": "2026-11-05T16:02:11.000Z"
}

user.role is admin for an AM (or anyone with admin.system), qc_lead for anyone with core.bot_run, otherwise the person's own role code. Retries follow the schedule above (network errors and 5xx only), so the runner may see a message twice if its 2xx reply is lost; messageId identifies duplicates. Deliveries show in the Bots activity log as chat.message.

8. Proposing new tools (e.g. QC)

New tools are written into the CORE codebase by Bruce, from a plan you provide. Send one proposal per tool using the template below. The clearer the plan, the faster it ships to sandbox for you to test.

Design rules (how CORE tools are built)

  • Tools sit on top of CORE's REST API. Each tool calls existing CORE routes (or a new bot route Bruce adds) as your bot. It never writes to the database directly, so validation, permissions, locks and the audit log always apply. If no route does what you need, say so: the plan then includes a new route.
  • One job per tool. Prefer several small, clearly named tools (get_qc_status, list_qc_findings) over one tool with a mode switch.
  • Read vs write is explicit. Mark each tool Read or Write. Writes must be safe to retry (idempotent), or say exactly what happens if called twice.
  • Irreversible or outward-facing actions need guard words in the description (like create_zoho_deal's "only when the user explicitly asked"), because the model reads the description to decide when to call a tool.
  • Inputs are typed and minimal. Use ids from other tools (project id, Pre-Core id), enums for fixed choices, and limits on sizes.
  • Outputs are compact JSON, only the fields the bot needs. Files come back as 15-minute download links, not as file contents.
  • Errors are sentences the model can act on ("not found", "someone is editing this project, try later", "missing field X"), not stack traces.
  • Mind the BOT role. It can view and edit Pre-Core and CORE projects, but has no admin rights and can't reopen completed studies. A tool needing more access must say why.
  • Respect frozen studies. A completed study's allocation must not change unless someone deliberately changes it. Tools that would edit a completed project must explain why, and Bruce decides.

Proposal template (copy one per tool)

TOOL NAME:        snake_case_verb_noun        (e.g. get_qc_findings)
TYPE:             Read | Write
ONE-LINE PURPOSE: What the bot uses it for, in plain English.

WHEN TO CALL IT:  The description the model will see. Include any "only when…"
                  guard for writes or anything irreversible.

INPUTS:
  name          type        required?  rules / example
  projectId     integer     yes        a CORE project id (from search_projects)
  status        enum        no         one of: open | resolved   (default open)

OUTPUT (example JSON):
  { "projectId": 875, "findings": [ { "rule": "3.4.1", "status": "FAIL", "note": "…" } ] }

WHAT IT READS / CHANGES IN CORE:
  Screens, data or records involved (e.g. "the QC1 review checklist on a project").
  If it writes: exactly what changes, and what calling it twice does.

ERRORS TO EXPECT:  not found, locked project, missing data, … and the message to return.

WHO SHOULD HAVE IT: Your bot only, or also other bots (e.g. Office Bot).

EXAMPLE PROMPTS:  2–3 things a user would say that should trigger this tool.

TEST PLAN:        How you'll test it on sandbox, and what "working" looks like.

OPEN QUESTIONS:   Anything you're unsure CORE has or allows.
What happens after you send itBruce reviews it, implements it in backend/core/mcp-server.js (plus any new route), and deploys to sandbox. Your bot sees it immediately (reconnect GrokBot). Once you've tested it, Bruce merges it to production and turns it on for whichever bots should have it.

9. Limits & gotchas

ThingDetail
Rate limit60 MCP requests per minute per bot. Over that you get a rate-limit error (logged).
Data resetsEvery clone replaces sandbox with a fresh copy of production. Ids you saved may point at different data afterwards; look them up again.
Download linksValid 15 minutes, no login, plain GET. Report generation happens when the link is opened.
query_databaseSingle SELECT only, max 200 rows, separate read-only login; sensitive tables are blocked. Use TOP and aggregates.
LocksIf a person has a project open in CORE, writes to it are refused with a clear message. Retry later, not in a tight loop.
New tools not showingReconnect the GrokBot connector (the tool list is cached on connect), and confirm the deploy reached sandbox.
Everything is loggedEvery call (inputs, results, errors, your context) is visible to admins in Bots → Activity; data changes appear in the Audit Log under your bot's name.

10. For admins (Bruce, Zack, Andy)

Bots are managed in Administrator Functions, the tool reached from the app picker after signing in to CORE. It needs System administration rights. Everything below is on the Bots tab.

Do lasting changes on productionProduction is the source of every sandbox clone. Bots, keys, routines and tool choices made on production come back after every clone; anything changed on sandbox is replaced by the next one. Use sandbox's Bots tab only for throwaway tests.

Where things are

AreaWhat it's for
Bots listEvery bot with its owner (who it works for), keys working here, routines, last activity and on/off. Shows "Tools: n of N" or "Tools: all". + New Bot creates one; Manage opens its window.
Manage windowName, owner and Active. Tools: which tools it can use. API keys: issue and revoke, per environment. Own routines: webhooks CORE calls for this bot. Retire bot: turns it off, revokes every key and removes its routines in one step; its history is kept.
API Keys listEvery key, its bot and environment, last use and 7-day calls. Tools (n) shows the tools that key's bot can call, with per-tool usage and failures. Revoke takes effect immediately and can't be undone.
ActivityEvery tool call, report download, notice CORE sent, token exchange and bad-key attempt, newest first. Click a row for exactly what the bot sent and got back. Filter by bot, time, type, tool, outcome, project or Pre-Core id; search inputs, results and bot context. Export CSV. The open-in-new-tab icon opens a live log that updates every few seconds.
Changes made / Reports generatedEvery record a bot created or changed (field by field) and every report it produced.
Clear logDeletes the Activity entries matching the current filters, after telling you how many; the clear itself is recorded in the Events tab. History is otherwise kept 90 days.

Choosing a bot's tools

Manage → Tools has two modes:

  • Only the tools ticked below. The normal choice. A checklist of every tool on this server, with Read/Write and a description (Tick all / Untick all). Tools added to CORE later start off for this bot until ticked.
  • All tools, including ones added later. For a developer's bot, like Andy's, so new tools appear on sandbox without anyone re-ticking after each clone.

Click Save tools; an "Unsaved changes" note shows until you do. A bot only sees its allowed tools. If it calls another one, the call is refused ("Tool … not found") and shows in Activity as "This bot isn't allowed to use this tool". New bots start with every current tool ticked. This controls which tools a bot can use; the BOT role still decides what each tool may change.

Prospect-only bots (mailer estimates)

A bot that only runs mailer estimates should be prospect-only. It then:

  • sees only the prospect tools (the four Pre-Core tools, always forced to destination: 'prospect', plus create_prospect_batch, update_prospect and list_prospects), whatever is ticked for it;
  • can't swap its key for a session token (/api/core/bot/token answers 403);
  • is refused on every other route, even with a token it got some other way.

Make one with the key script: node scripts/issue-bot-api-key.js --email <new bot email> --name "Prospector" --label prospector --env sandbox --prospect-only. The limit is on the bot, so keys issued later from Manage → API keys are limited too. The Bots list marks it Prospect-only. Other bots can be given the prospect tools as well, by ticking them.

The card (v2, from October 26, 2026). Two US Letter pages, Zack's design (backend/eob-templates/prospect-card-v2/). Page 1: the photo, the address, the estimated tax savings for the tax year, and stat boxes for extra first-year depreciation, return on the study fee and bonus depreciation (a box is left off when Core has no value for it, for example no bonus). Page 2 opens with a personal note, then the savings breakdown and the contact block. What the bot sends that shows on it, in prospect:

  • mailToName: the person the card is for; the note greets them by first name (“Hi Kade,”) and mailToCompany goes on the line below. With no person, the card is addressed to the company.
  • noteText: the personal note, 2–3 sentences about this property. Without one the card uses a general line.
  • priceSourceShort (25 characters at most, e.g. “Redfin-reported”): printed as “est., Redfin-reported” next to an unverified purchase price (a leading “est.” in the value is dropped, so it never doubles). priceVerified: true drops the “est.”.
  • landSource (e.g. “county assessor”, the default): shown in “Less land (30%, county assessor)”.
  • photoBase64 and photoCredit: the photo fills the top of page 1; the credit goes in the fine print.

The long-life label is 27.5 years for a Residential recovery period and 39 for Commercial. Other properties of the same owner aren't listed yet (one card per prospect). The contact block defaults to Zack (sender.json, his headshot and signature); the server settings PROSPECT_REP_NAME, PROSPECT_REP_PHONE and PROSPECT_REP_BIO override it. No title is printed under the name. Saving cards to Drive needs Core's Google service account to be a member (Content manager) of the Shared Drive holding _Prospect Mailers; Core finds that folder by name, or uses PROSPECT_MAILERS_FOLDER_ID when set (e.g. if two folders share the name).

Photos after mailing. When a prospect is marked status: 'mailed' and its card is saved in Drive, Core deletes its copy of the photo (the mailed PDF in Drive keeps it). The prospect then reads hasPhoto: false, photoCleared: true; a prospect that never had a photo reads photoCleared: false. A prospect marked mailed without a Drive card keeps its photo. Asking for a cleared prospect's card (download link or saveToDrive) is refused with a link to the mailed card, so a re-save can't replace it with one missing the photo; send photoBase64 again with update_prospect to make a new card.

Keys & routines

  • Issuing a key: Manage → API keys → label + environment → Issue key. The key is shown once; copy it straight away. A key only works in the environment it was issued for.
  • Keys for sandbox: issue them on production with environment sandbox. They do nothing on production and start working on sandbox after the next clone, and every clone after that.
  • Routines: Manage → Own routines → event, https URL, optional Authorization header, environment → Add routine. Generate secret creates a signing secret (shown once); the receiver checks X-Core-Signature. Routines tagged for another environment never fire here, and a clone switches them off on the server they don't belong to.
  • Turning a bot off (untick Active) stops all its keys and notices at once; Retire bot does that permanently.

Sandbox & clones

  • Refreshing sandbox: sign in to the sandbox site; on the app picker, click Sync From Production DB (System administration only). It copies the whole production database over sandbox and takes a few minutes; everything on sandbox is replaced.
  • After a clone, sandbox keeps its own code (whatever is deployed from the sandbox branch) and its own Railway settings; only the data changes.
  • People sign in to sandbox with their production accounts (copied by the clone). No separate sandbox users are needed.

Rolling out a new tool (e.g. Andy's QC tools)

  1. Proposal: Andy sends a proposal per tool (template in section 8).
  2. Build: Bruce implements it on a branch and pushes it to sandbox. Andy's bot ("all tools") sees it immediately after reconnecting GrokBot.
  3. Test: Andy tests on sandbox. Admins watch Activity on sandbox for errors.
  4. Ship: Bruce runs any database migration on production, then merges sandbox → master.
  5. Turn it on on production: Manage → Tools on each bot that should have it (e.g. Office Bot) → tick it → Save tools. Bots on "only ticked" won't get it otherwise.
  6. Refresh: those bots' owners reconnect their GrokBot connectors to pick up the new tool.

Watching the bots

  • The Bot Activity card on the apps page (open to every CORE user) lists the requests bots recorded with open_bot_request, with their status and steps. Bots only appear there once their developers add the request calls (see Tracking requests); the existing bots were given open_bot_request and update_bot_request in Manage → Tools.
  • The status strip on the Bots tab shows when bots were last active, call and failure counts, report downloads, whether the last "project completed" notice was delivered, and any bad-key attempts or rate-limit hits.
  • "isn't allowed to use this tool" entries in Activity mean a bot tried a tool that isn't ticked for it. Either tick it or fix the bot's prompt.
  • A run of "bad key" attempts usually means a bot is using a revoked key or a key from the other environment. When the key never arrived in X-Api-Key, the entry's error and its problem detail say where it went instead (for example "The key was sent in the Authorization header"); keyStartsWith: (none) means no key was sent at all.
  • In the Audit Log, bot changes appear as "Bot name (for Owner)".

"Run engineering bots" and the runner

  • Administrators (AM, permission core.bot_run) start the engineering bots from a project's Overview tab. CORE calls the runner service, records the run in core_bot_runs (who, when, step, cost, result), and shows its status on the project.
  • CORE needs two environment variables: RUNNER_URL (on Railway the private address, e.g. http://<runner service>.railway.internal:8080) and RUNNER_SECRET (the same value set on the runner; sent as X-Runner-Secret). Without them the button stays greyed out with "The bot runner is not set up on this server".
  • Production only. The runner reads production CORE's database and writes through production's MCP endpoint, so only a backend with APP_ENV=production starts runs. On sandbox and dev the button is greyed out with "Engineering bots run on production Core only." and the start route returns 400 without calling the runner. Leave RUNNER_URL blank on sandbox as a second safeguard.
  • Runner API CORE uses: POST /runs {project_id, requested_by, role: "qc_lead", write: true, instructions, core_env, core_url}, GET /runs/:projectId (running, exit_code, steps, cost_usd, messages), POST /runs/:projectId/cancel. core_env is APP_ENV (lower case); core_url is this backend's public address, https:// + RAILWAY_PUBLIC_DOMAIN, or CORE_PUBLIC_URL off Railway (not APP_BASE_URL, which is the website). The runner refuses anything that isn't production. Its 403 (with its own reason) / 409 / 429 come back to the person as plain messages.
  • While a run is going, people can't save assets, subassets, square-foot models or takeoffs on that project (423 BOT_RUN_ACTIVE); the bots' own writes go through even if someone has the project open. A run the runner no longer knows about is closed when CORE next checks, and after 12 hours with no word it's closed so the project unlocks.
  • Logs. CORE checks every running run once a minute, even when nobody has the project open. Server log lines (starting [bot-runs] or Bot runner unreachable) name the run, the project, the runner host and the cause (DNS lookup failed, connection refused, timed out, HTTP status). They go to Sentry as follows: runner unreachable at start, a refused run (401 also says RUNNER_SECRET doesn't match), a cancel that didn't reach the runner, and a run closed after 12 hours are errors; busy (429) / already running (409) and 15 minutes without word from the runner are warnings; the first missed check, a runner answering again, and a run that ended stopped / failed are log-only. Each run's record in core_bot_runs keeps the result, the reason, the last step, the cost, the runner's last status, and last_contact_at / missed_since / miss_reason.
  • Bot Run Finished (Notification Triggers → bot_run_finished): created on first use, active, emailing the person who started the run (its "Also notify" option). Add fixed recipients there.