You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Single source of truth for LLM agents and developers working on this codebase.
Read this before exploring code. AGENTS.md requires it.
1. System Overview
InfraForge is an enterprise self-service infrastructure platform. Users describe
infrastructure needs in natural language; the platform searches an approved template
catalog, composes ARM templates from building blocks, validates against governance
policies, estimates costs, and deploys directly to Azure — all without writing IaC
by hand.
Stack
Layer
Technology
Backend
FastAPI (Python 3.13, uvicorn)
Database
Azure SQL Database (pyodbc + AAD)
AI Engine
GitHub Copilot SDK (Python)
Auth
Microsoft Entra ID (MSAL.js + MSAL Python)
Identity
Microsoft Graph (Entra ID org data)
M365 Intelligence
Microsoft Work IQ (MCP Server)
Analytics
Fabric IQ (OneLake + Fabric Semantic Models)
Frontend
Vanilla JS SPA (no framework)
Deployment
ARM SDK (azure-mgmt-resource)
Server Port
8080 (configurable via INFRAFORGE_WEB_PORT)
Key Design Principles
Catalog-first — Always search approved templates before generating from scratch.
Governance-first — Check service approval status before generating any infrastructure.
All data in Azure SQL — No local JSON files for persistent state. Every table uses
IF NOT EXISTS guards for idempotent schema creation.
SQL Server syntax — Use TOP N (not LIMIT), COALESCE, NVARCHAR. Never use
MySQL/PostgreSQL-only syntax.
Semantic versioning — Templates and services track versions with semver strings
(e.g., 1.2.0), stored in the semver column. Integer version is the ordinal
auto-increment; semver is the display version.
No debug_*.py, test_*.py, fix_*.py, check_*.py scripts.
No *_old.* backup files.
No local JSON mock data files.
The output/ directory is gitignored.
3. Data Model (Azure SQL)
All persistent data lives in Azure SQL Database. Schema is defined in
database.py::AZURE_SQL_SCHEMA_STATEMENTS and standards.py::_STANDARDS_SCHEMA.
Tables are created automatically on startup via init_db().
Core Tables
Table
Purpose
Key Columns
services
Azure service catalog
id (resource type), name, category, status, risk_tier, active_version
service_versions
Versioned ARM templates per service
service_id, version (int), semver (string), arm_template, status
All endpoints are in src/web.py. The app is a single FastAPI instance on port 8080.
Auth & Settings
Method
Path
Description
GET
/
Serve the SPA
GET
/api/version
App name and version
GET
/api/auth/config
Entra ID client config for MSAL.js
GET
/api/auth/login
Initiate Entra ID login
GET
/api/auth/callback
OAuth2 callback
POST
/api/auth/logout
Logout
GET
/api/auth/me
Current user info
GET
/api/settings/model
Current LLM model
GET
/api/settings/model-routing
Task→model routing table
PUT
/api/settings/model
Change active chat model
Service Catalog
Method
Path
Description
GET
/api/catalog/services
List all services with hydrated policies/SKUs/regions
POST
/api/catalog/services
Add a new service
PATCH
/api/catalog/services/{id}
Update service status/metadata
DELETE
/api/catalog/services/{id}
Remove a service
GET
/api/catalog/services/approved-for-templates
Services with active ARM templates
GET
/api/catalog/services/sync
Trigger Azure resource provider sync
GET
/api/catalog/services/sync/status
Sync progress (SSE stream)
GET
/api/catalog/services/sync/stats
Last sync statistics
GET
/api/services/{id}/versions
List all versions of a service
GET
/api/services/{id}/versions/{ver}
Get specific version
POST
/api/services/{id}/versions/{ver}/mark-active
Set active version
GET
/api/services/{id}/artifacts
Get approval gate artifacts
PUT
/api/services/{id}/artifacts/{type}
Save an artifact
POST
/api/services/{id}/artifacts/{type}/generate
Generate artifact via LLM
POST
/api/services/{id}/artifacts/{type}/validate
Validate an artifact
POST
/api/services/{id}/validate-deployment
Deploy to Azure for validation
POST
/api/services/{id}/onboard
Full onboarding pipeline (NDJSON stream)
POST
/api/services/{id}/artifacts/{type}/heal
Auto-heal a failed artifact
Template Catalog
Method
Path
Description
GET
/api/catalog/templates
List all templates
POST
/api/catalog/templates
Register a template
DELETE
/api/catalog/templates/{id}
Remove a template
POST
/api/catalog/templates/compose
Compose from approved services
POST
/api/catalog/templates/compose-from-prompt
Compose from natural language
GET
/api/catalog/templates/{id}/composition
Service dependencies with semver
GET
/api/catalog/templates/{id}/versions
Version history
POST
/api/catalog/templates/{id}/versions
Create a new version
POST
/api/catalog/templates/{id}/promote
Promote a version
POST
/api/catalog/templates/{id}/test
Run structural tests
POST
/api/catalog/templates/{id}/auto-heal
Auto-heal failed tests
POST
/api/catalog/templates/{id}/recompose
Recompose with updated services
POST
/api/catalog/templates/{id}/validate
Full validation pipeline (NDJSON)
POST
/api/catalog/templates/{id}/publish
Publish to catalog
POST
/api/catalog/templates/{id}/deploy
Deploy to Azure
POST
/api/catalog/templates/{id}/feedback
Analyze user feedback for revision
POST
/api/catalog/templates/{id}/revision/policy-check
Policy check before revision
POST
/api/catalog/templates/{id}/revise
Apply a revision (add services or code edit)
Template Analysis
Method
Path
Description
GET
/api/templates/types
Template type definitions
GET
/api/templates/known-dependencies
Resource dependency map
POST
/api/templates/analyze-dependencies
Analyze dependencies for resource types
GET
/api/templates/discover/{resource_type}
Discover ARM API version for a type
GET
/api/templates/discover-subnets
Discover existing subnets in a VNET
Governance
Method
Path
Description
GET
/api/governance/security-standards
All security standards
GET
/api/governance/compliance-frameworks
Compliance frameworks + controls
GET
/api/governance/policies
All governance policies
GET
/api/approvals
All approval requests
GET
/api/approvals/{id}
Single approval request
POST
/api/approvals/{id}/review
Review (approve/deny) a request
Standards API (mounted via standards_api.py)
Method
Path
Description
GET
/api/standards
List (filter: ?category=, ?enabled_only=)
POST
/api/standards
Create
GET
/api/standards/categories
Distinct categories
GET
/api/standards/{id}
Get one
PUT
/api/standards/{id}
Update (creates version history)
DELETE
/api/standards/{id}
Delete + history
GET
/api/standards/{id}/history
Version history
GET
/api/standards/for-service/{service_id}
Standards matching a service
GET
/api/standards/context/policy/{service_id}
Policy prompt context
GET
/api/standards/context/arm/{service_id}
ARM prompt context
Deployments & Activity
Method
Path
Description
GET
/api/deployments
All deployment records
GET
/api/deployments/{id}
Single deployment
GET
/api/deployments/{id}/stream
Deployment progress (SSE)
GET
/api/activity
Activity feed
GET
/api/analytics/usage
Usage analytics
Orchestration
Method
Path
Description
GET
/api/orchestration/processes
Active orchestration processes
GET
/api/orchestration/processes/{id}
Process detail
GET
/api/orchestration/processes/{id}/playbook
Process playbook
WebSocket
Path
Description
ws://localhost:8080/ws/chat
Infrastructure Designer chat (Copilot SDK agent)
5. Frontend Architecture
The frontend is a vanilla JavaScript SPA with no build step.
Files
File
Lines
Purpose
index.html
~940
SPA shell with all page containers, modals, drawers
app.js
~6200
All application logic, API calls, rendering
styles.css
~7200
All styling (dark theme, component styles)
Cache Busting
Static files are loaded with a version query parameter: app.js?v=66.
Bump this version in index.html after every change to JS or CSS.
Current cache version: v66.
Key Patterns
Navigation: navigateTo(page) — shows/hides .page divs, updates nav state.
Data loading: loadAllData() — fetches services, templates, approvals in parallel.
Template detail: Full-page overlay drawer (#template-detail-drawer) with sidebar
showing composition info and version history.
Service detail: Drawer (#service-detail-drawer) with approval gates and artifacts.
Validation: NDJSON streaming via fetch() with ReadableStream. Progress is tracked
in _activeTemplateValidations global, which persists across panel close/reopen.
Chat: WebSocket connection to /ws/chat with markdown rendering and tool call display.
HTML escaping: All user content is escaped via escapeHtml() before innerHTML.
CSS Naming Conventions
Prefix
Scope
tmpl-*
Template-related components
comp-*
Composition sidebar components
svc-*
Service catalog components
ver-*
Version pipeline components
nav-*
Navigation components
stat-*
Dashboard stat cards
6. Copilot SDK Tools
Tools are defined in src/tools/ and registered via src/tools/__init__.py.
Each tool uses @define_tool from the Copilot SDK with Pydantic input models.
Registered Tools (29 total)
Tool
File
Data Source
search_template_catalog
catalog_search.py
Database
compose_from_catalog
catalog_compose.py
Database
register_template
catalog_register.py
Database
generate_bicep
bicep_generator.py
Copilot SDK
generate_terraform
terraform_generator.py
Copilot SDK
generate_github_actions_pipeline
github_actions_generator.py
Patterns
generate_azure_devops_pipeline
azure_devops_generator.py
Patterns
generate_architecture_diagram
diagram_generator.py
Copilot SDK
generate_design_document
design_document.py
Copilot SDK
estimate_azure_cost
cost_estimator.py
Hard-coded (see §10)
check_policy_compliance
policy_checker.py
Database
save_output_to_file
save_output.py
Local filesystem
publish_to_github
github_publisher.py
GitHub API
check_service_approval
service_catalog.py
Database
request_service_approval
service_catalog.py
Database
list_approved_services
service_catalog.py
Database
get_approval_request_status
service_catalog.py
Database
review_approval_request
service_catalog.py
Database
list_security_standards
governance_tools.py
Database
list_compliance_frameworks
governance_tools.py
Database
list_governance_policies
governance_tools.py
Database
validate_deployment
deploy_engine.py
Azure ARM SDK
deploy_infrastructure
deploy_engine.py
Azure ARM SDK
get_deployment_status
deploy_engine.py
Azure ARM SDK + Database
search_org_knowledge
workiq_tools.py
Microsoft Work IQ (M365)
find_related_documents
workiq_tools.py
Microsoft Work IQ (M365)
find_subject_matter_experts
workiq_tools.py
Microsoft Work IQ (M365)
7. Model Router
src/model_router.py routes each LLM task to the optimal model. This is separate
from the user's chat model preference.
Task → Model Mapping
Task
Model
Rationale
PLANNING
claude-sonnet-4
Architecture planning + root cause analysis
VALIDATION_ANALYSIS
claude-sonnet-4
Analyzing deployment errors and policy violations
CODE_GENERATION
claude-sonnet-4
Precise ARM/Bicep/Terraform generation
POLICY_GENERATION
claude-sonnet-4
Precise policy JSON structure
CODE_FIXING
claude-sonnet-4
Surgical template healing
CHAT
(user-selected)
Interactive conversation
QUICK_CLASSIFY
gpt-4.1-nano
Fast classification and routing
DESIGN_DOCUMENT
gpt-4.1
Clear technical prose
GOVERNANCE_REVIEW
claude-sonnet-4
CISO/CTO structured review gate
Task Enum
fromsrc.model_routerimportTaskTask.PLANNING# NOT "Task.GENERATION"Task.CODE_GENERATION# The correct enum for code genTask.CODE_FIXINGTask.POLICY_GENERATIONTask.VALIDATION_ANALYSISTask.CHATTask.QUICK_CLASSIFYTask.DESIGN_DOCUMENTTask.GOVERNANCE_REVIEW
7b. Agent Architecture (DB-backed)
Agent definitions are stored in the agent_definitions table and loaded at server
startup. Hardcoded defaults in src/agents.py serve as fallback. Platform engineers
can iterate on prompts via the API without code changes or server restarts.
Storage
Table
Purpose
agent_definitions
Agent specs: name, prompt, task, timeout, enabled
agent_prompt_history
Version history for every prompt change
Agent Registry (26 agents)
ID
Name
Category
Task
Used By
web_chat
InfraForge Chat
Interactive
CHAT
WebSocket chat
governance_agent
Governance Advisor
Interactive
CHAT
Governance page chat
ciso_advisor
CISO Advisor
Interactive
CHAT
CISO chat mode
concierge
InfraForge Concierge
Interactive
CHAT
Concierge chat mode
gap_analyst
Gap Analyst
Orchestrator
PLANNING
orchestrator.py
arm_template_editor
ARM Template Editor
Orchestrator
CODE_GENERATION
orchestrator.py
policy_checker
Governance Policy Checker
Orchestrator
PLANNING
orchestrator.py
request_parser
Request Parser
Orchestrator
PLANNING
orchestrator.py
standards_extractor
Standards Extractor
Standards
PLANNING
standards_import.py
arm_modifier
ARM Template Modifier
ARM Gen
CODE_GENERATION
arm_generator.py
arm_generator
ARM Template Generator
ARM Gen
CODE_GENERATION
arm_generator.py
template_healer
Template Healer
Pipeline
CODE_FIXING
pipeline_helpers.py
error_culprit_detector
Error Culprit Detector
Pipeline
PLANNING
web.py
deploy_failure_analyst
Deploy Failure Analyst
Pipeline
VALIDATION_ANALYSIS
deploy.py
remediation_planner
Remediation Planner
Compliance
PLANNING
web.py
remediation_executor
Remediation Executor
Compliance
PLANNING
web.py
artifact_generator
Artifact Generator
Artifact
CODE_GENERATION
web.py
policy_generator
Policy Generator
Pipeline
POLICY_GENERATION
onboarding.py
policy_fixer
Policy JSON Fixer
Healing
CODE_FIXING
onboarding.py
deep_template_healer
Deep Template Healer
Healing
CODE_FIXING
pipeline_helpers.py
llm_reasoner
LLM Reasoner
Healing
PLANNING
onboarding.py, web.py
upgrade_analyst
Upgrade Analyst
Orchestrator
VALIDATION_ANALYSIS
orchestrator.py
infra_tester
Infrastructure Tester
Testing
CODE_GENERATION
testing.py
infra_test_analyzer
Test Analyzer
Testing
VALIDATION_ANALYSIS
testing.py
ciso_reviewer
CISO Reviewer
Governance
GOVERNANCE_REVIEW
governance.py
cto_reviewer
CTO Reviewer
Governance
GOVERNANCE_REVIEW
governance.py
API Endpoints
Method
Path
Description
GET
/api/agents/activity
Full registry, routing table, and activity log
GET
/api/agents/{id}/prompt
Get full system prompt
PUT
/api/agents/{id}/prompt
Update prompt (versioned, persisted to DB)
POST
/api/agents/{id}/reset
Reset prompt to hardcoded default
GET
/api/agents/{id}/history
Prompt version history
PATCH
/api/agents/{id}
Update metadata (name, timeout, enabled)
Loading Order
_HARDCODED_AGENTS dict in agents.py — always available at import time
seed_agent_definitions() — inserts missing agents into DB during init_db()
load_agents_from_db() — overlays DB definitions onto AGENTS dict at startup
DB definitions take precedence; disabled agents are removed from AGENTS
Pipeline Agent Flow
User Request
│
├─ WebSocket Chat ──▶ WEB_CHAT_AGENT (interactive, with tools)
│
├─ Service Onboarding Pipeline (12 steps):
│ ├─ initialize ──▶ (no LLM — model routing, cleanup stale drafts)
│ ├─ check_dependency_gates ──▶ (recursive sub-pipeline for unvalidated deps)
│ ├─ analyze_standards ──▶ (no LLM — DB fetch for org standards)
│ ├─ plan_architecture ──▶ LLM_REASONER
│ ├─ generate_arm ──▶ ARM_GENERATOR
│ ├─ generate_policy ──▶ POLICY_GENERATOR (LLM + deterministic fallback)
│ ├─ governance_review ──▶ CISO_REVIEWER + CTO_REVIEWER (heal loop, up to 5 rounds)
│ ├─ validate_arm_deploy ──▶ TEMPLATE_HEALER (heal loop):
│ │ JSON parse → static policy → ARM expression syntax
│ │ → What-If → deploy → resource verify
│ │ → runtime policy compliance (policy heal sub-loop, up to 3 rounds)
│ ├─ infra_testing ──▶ INFRA_TESTER → INFRA_TEST_ANALYZER
│ ├─ deploy_policy ──▶ policy_deployer.py (deploys Azure Policy to Azure)
│ ├─ cleanup ──▶ cleanup_rg() (delete validation RG + policy)
│ └─ promote_service ──▶ (DB: mark approved, set active version, optional child co-onboard)
│
├─ Template Validation Pipeline (10 steps):
│ ├─ initialize_template ──▶ (no LLM — load template, model routing, conflict check)
│ ├─ recompose_template ──▶ (no LLM — blueprint: recompose from pinned services)
│ ├─ structural_test ──▶ (no LLM — 7-category structural test suite)
│ ├─ auto_heal_structural ──▶ TEMPLATE_HEALER (CODE_FIXING — fix structural failures)
│ ├─ pre_validate_arm ──▶ TEMPLATE_HEALER (expression syntax fix if needed)
│ ├─ check_availability ──▶ (no LLM — quota check, region fallback)
│ ├─ arm_deploy_template ──▶ TEMPLATE_HEALER (heal loop, up to 5×):
│ │ ARM expression syntax → What-If → deploy
│ │ Deep heal for blueprints: ERROR_CULPRIT_DETECTOR (PLANNING)
│ ├─ infra_testing_template ──▶ INFRA_TESTER → INFRA_TEST_ANALYZER
│ ├─ cleanup_template ──▶ cleanup_rg() (delete validation RG)
│ └─ promote_template ──▶ (DB: mark validated, complete pipeline run)
│
└─ Template Deploy Pipeline:
├─ what_if + deploy ──▶ TEMPLATE_HEALER
├─ deep_heal ──▶ DEEP_TEMPLATE_HEALER
└─ failure_summary ──▶ DEPLOY_FAILURE_ANALYST
Session API
fromcopilotimportCopilotClient, CopilotSession# Creating a sessionsession: CopilotSession=awaitcopilot_client.create_session(model=model_id)
# Event handling — session.on() returns an UNSUBSCRIBE functionunsub=session.on(on_event)
try:
response=awaitasyncio.wait_for(session.send_message(...), timeout=90)
finally:
unsub() # Always clean up
CRITICAL: The correct API is session.on(callback) which returns an unsubscribe
function. There is nosession.on_event() method. Always use the pattern above.
9. Template Revision Flow
When users request changes to a template, there are two paths:
Path 1: Add Services (should_recompose=True)
User asks for new resource types → recompose the template with additional services.
Path 2: Modify Existing (needs_code_edit=True)
User asks to change existing resources (reduce count, change SKU, modify config) →
apply_template_code_edit() sends current ARM JSON + instruction to LLM for direct editing.
Detection
analyze_template_feedback() in orchestrator.py classifies the request:
LLM analysis (primary) — returns category: "add_services" or "modify_existing"
Heuristic fallback — detects modification-signal words ("reduce", "should be",
"too many", "change", "provisioning 2") and routes to code edit.
10. Known Hard-coded Data
Cost Estimator (cost_estimator.py)
Contains ~40 hard-coded Azure price points in AZURE_PRICING dict. This is a known
limitation — prices are approximate and not sourced from the Azure Retail Prices API
or the database. Environment multipliers (dev=0.5×, staging=0.75×, prod=1.0×) are
also static.
ARM Generation Helpers (arm_generator.py)
Shared ARM generation/editing helpers now route service template creation through the
Copilot SDK. The module keeps standard parameter/template metadata, response cleanup,
and template post-processing helpers used by onboarding, recovery, and modification flows.
Resource Dependency Map (template_engine.py)
RESOURCE_DEPENDENCIES dict maps Azure resource types to their dependencies. This is
hard-coded in src/template_engine.py as a performance optimization — looking up
dependencies in the DB for every composition would add latency.
Category Inference
Category inference uses NAMESPACE_CATEGORY_MAP from azure_sync.py — a ~55-entry
dict mapping Azure provider namespaces to categories. The orchestrator's _infer_category
delegates to this map (unified, no longer duplicated).
11. Server Management
Start the server
# Preferred method (detached, won't die when terminal closes):$env:PYTHONIOENCODING="utf-8"Start-Process-FilePath ".\.venv\Scripts\python.exe"-ArgumentList "web_start.py"`-WorkingDirectory "C:\Users\aharsan\projects\CopilotSDKChallenge"`-NoNewWindow -RedirectStandardOutput "server.log"-RedirectStandardError "server_err.log"
Branch per change: fix/description, feat/description, chore/description
Merge with --no-ff to preserve branch history
Commit after every logical change
Frontend
Bump ?v=N in index.html after every JS/CSS change
Run node --check static/app.js before committing
Use escapeHtml() for all user-generated content in innerHTML
Python
Server restart after every backend change
Check server_err.log for import/syntax errors after restart
Use Task.CODE_GENERATION not Task.GENERATION (the latter doesn't exist)
13. Environment Variables
Variable
Required
Default
Description
AZURE_SQL_CONNECTION_STRING
Yes
—
Azure SQL Database connection string
COPILOT_MODEL
No
gpt-4.1
Default Copilot model
COPILOT_LOG_LEVEL
No
warning
SDK log verbosity
SESSION_SECRET
No
dev default
Session middleware secret
ENTRA_CLIENT_ID
No
—
Microsoft Entra ID app client ID
ENTRA_TENANT_ID
No
—
Azure AD tenant ID
ENTRA_CLIENT_SECRET
No
—
Entra ID client secret
ENTRA_REDIRECT_URI
No
localhost:8080
Auth callback URL
GITHUB_TOKEN
No
—
GitHub API token for publishing
GITHUB_ORG
No
—
GitHub org for repo creation
INFRAFORGE_OUTPUT_DIR
No
./output
Directory for saved files
INFRAFORGE_WEB_HOST
No
0.0.0.0
Server bind host
INFRAFORGE_WEB_PORT
No
8080
Server port
FABRIC_WORKSPACE_ID
No
—
Microsoft Fabric workspace ID
FABRIC_ONELAKE_DFS_ENDPOINT
No
—
OneLake DFS endpoint URL
FABRIC_LAKEHOUSE_NAME
No
—
OneLake lakehouse name
14. Entra ID — App Registration & Authentication
InfraForge authenticates users via Microsoft Entra ID using the OAuth2 authorization
code flow. The setup script (scripts/setup.ps1 Step 3) creates the required App
Registration automatically.
App Registration Configuration
Setting
Value
Display Name
InfraForge
Sign-in audience
Single tenant (org directory only)
Redirect URI
http://localhost:8080/api/auth/callback (Web)
Client Secret
Auto-generated, 1-year expiry
Optional Claims (ID token)
email, upn
Group Claims
SecurityGroup — emitted in both ID and access tokens
Returns Entra ID client config for MSAL.js (client ID, tenant, scopes)
GET /api/auth/login
Initiates OAuth2 login (requires Entra ID)
GET /api/auth/callback
OAuth2 redirect — exchanges code for tokens
POST /api/auth/logout
Clears session
GET /api/auth/me
Returns current user context
Identity Intelligence — Microsoft Graph Enrichment
Entra ID enriches every user session with organizational context from Microsoft Graph:
Identity-aware tagging — Resources are automatically tagged with the user's
email, department, cost center, and manager
Role-based access — PlatformTeam group membership grants full catalog access;
standard users work with approved templates
Cost attribution — Every action logged in usage_logs with department/cost center
Approval routing — Design documents routed based on manager chain from Graph API
Required Permissions
Permission
Scope
Purpose
App registration creation
Entra ID
Setup script creates the app
Admin consent for group claims
Entra ID
SecurityGroup claims in tokens
User.Read
Delegated (MS Graph)
Read the signed-in user's profile
User.ReadBasic.All
Delegated (MS Graph)
Read manager chain
15. Fabric IQ — Enterprise Analytics
InfraForge integrates with Microsoft Fabric to provide cross-organization analytics
via OneLake. The src/fabric.py module implements the sync engine, REST client,
and analytics computations.
Adoption metrics, status distribution, onboarding velocity
Deployments
Regional distribution, resource group usage, ARM SDK outcomes
Compliance
Framework scores (SOC2, CIS, HIPAA), control pass rates
API Endpoints
Method
Path
Description
GET
/api/fabric/health
Fabric connectivity status
POST
/api/fabric/sync
Trigger ETL sync to OneLake
GET
/api/analytics/dashboard
Real-time analytics dashboard data
Authentication
Fabric uses DefaultAzureCredential (the same credential used for Azure SQL)
to authenticate to both the Fabric REST API and OneLake DFS endpoints. No additional
app registration is required — the service principal or managed identity needs
Fabric workspace Contributor access.
16. Microsoft Work IQ — M365 Organizational Intelligence
InfraForge integrates with Microsoft Work IQ
(@microsoft/workiq) to query M365 organizational data via natural language, enriching
infrastructure decisions with context from emails, meetings, documents, Teams messages,
and people.
MCP stdio server declaration for @microsoft/workiq mcp
Tools
Tool
Purpose
Client Method
search_org_knowledge
General natural language search across all M365 data
client.ask(query)
find_related_documents
Search SharePoint/OneDrive for docs related to a topic
client.search_documents(topic)
find_subject_matter_experts
Find people with expertise in a domain
client.find_experts(domain)
Agent Integration
The main chat agent's system prompt (src/agents.py) instructs the LLM to:
Call search_org_knowledge before generating design documents
Use find_related_documents to discover existing architecture specs
Use find_subject_matter_experts to identify reviewers for approval chains
Gracefully continue if Work IQ is unavailable
Tools are registered in get_all_tools() (main agent only — not governance or concierge).
UI Visibility
Sidebar: "Org Intelligence" section with shortcuts for all 3 tools
Chat welcome: WORK IQ badge, M365 connection note, and cyan-themed suggestion chips
Tool activity: Branded spinner messages (e.g., "Searching org knowledge via Work IQ")
Authentication
Work IQ uses MSAL/WAM (Web Account Manager) browser-based authentication via Entra ID.
First-time setup requires npx -y @microsoft/workiq accept-eula followed by an
interactive login from a desktop terminal. Tokens are cached locally and reused by
the server. The availability check retries every 60 seconds so that auth changes
are picked up without a server restart.