This repository contains the MCP server that connects ESI's HR knowledge base (AWS Bedrock Knowledge Base backed by Aurora pgvector) to MCP-compatible clients (e.g. ChatGPT / MCP Inspector / internal agents).
The server exposes a single tool, retrieve_hr_policy, which lets HR agents and internal tools query the HR knowledge base and receive ranked chunks plus metadata (S3 path, page number, scores, etc.).
HR documents (handbook, PTO/leave, benefits, Unanet guides, state notices, etc.) are stored in S3 under:
s3://esi-hr-docs/...
An AWS Bedrock Knowledge Base indexes this bucket:
- Name:
esi-hr-kb-dev - Knowledge Base ID:
OLRJAOAVCZ - Region:
us-east-1 - Embedding model: Titan Text Embeddings v2 (or similar)
- Vector store: Amazon Aurora PostgreSQL (pgvector)
A scheduled Lambda + EventBridge job (hr-kb-scheduled-sync) runs StartIngestionJob for OLRJAOAVCZ and its S3 data source (XY5AQACOZ8) to keep the KB in sync with S3.
- This repo hosts a Node.js / TypeScript MCP server
- The server uses the Bedrock Agent Runtime client to call
Retrieveagainst the HR knowledge base - MCP-compatible clients call the
retrieve_hr_policytool and receive:- Retrieved content chunks
- S3 source locations
- Relevance scores
- Misc. Bedrock KB metadata
esi-hr-mcp/
├─ src/
│ └─ index.ts # MCP server + retrieve_hr_policy implementation
├─ build/ # Compiled JS output from npm run build
├─ .env # Optional local env vars (NOT committed)
├─ package.json
├─ tsconfig.json
└─ README.md # This file
- Node.js 18+ and npm
- AWS CLI configured with a profile that can access:
- The Bedrock Knowledge Base
OLRJAOAVCZ - Bedrock Agent Runtime in
us-east-1
- The Bedrock Knowledge Base
- Network access to AWS Bedrock endpoints from wherever this MCP server runs
The MCP server uses standard AWS SDK credential resolution (environment variables, config/credentials files, SSO profiles, etc.). It does not expose an HTTP server; it speaks MCP over stdio.
The server expects these environment variables at runtime:
AWS_REGION– AWS region where the KB lives (e.g.,us-east-1)AWS_PROFILE– (optional) AWS CLI profile to use for credentialsHR_KB_ID– Bedrock Knowledge Base ID (e.g.,OLRJAOAVCZ)
PowerShell example:
$env:AWS_PROFILE = "AdministratorAccess-285397596138"
$env:AWS_REGION = "us-east-1"
$env:HR_KB_ID = "OLRJAOAVCZ"
npm startIn Inspector's connection configuration (Environment Variables section), set:
AWS_PROFILE=AdministratorAccess-285397596138AWS_REGION=us-east-1HR_KB_ID=OLRJAOAVCZ
Note: There may be a
.envfile in the repo for convenience, but the current implementation does not automatically load it at runtime. If you want to re-enable.envloading, you can safely re-introducedotenvinsrc/index.tsas long as it does not print anything to stdout (which would conflict with MCP's JSON-over-stdio protocol).
From the repo root:
npm installnpm run buildThis compiles src/index.ts to build/index.js.
Set the environment variables (as above), then:
npm startYou should see log lines similar to:
esi-hr-kb-server MCP up on stdio
Starting esi-hr-kb-server with KB ID=OLRJAOAVCZ, region=us-east-1, profile=AdministratorAccess-285397596138
At this point, the process is waiting for an MCP client over stdio. It does not bind to an HTTP port (there is no http://localhost:3000).
You can use MCP Inspector to debug and explore the tool.
-
Build the project:
npm run build
-
Launch Inspector:
npx @modelcontextprotocol/inspector
-
In the Inspector UI, configure a new connection:
- Transport Type: STDIO
- Command:
node - Arguments:
build/index.js - Working directory: Path to this repo on your machine
(e.g.,C:\Users\<you>\Desktop\Career\ESI\EAAP - 31\esi-hr-mcp) - Environment variables:
AWS_PROFILE=AdministratorAccess-285397596138AWS_REGION=us-east-1HR_KB_ID=OLRJAOAVCZ
-
Click "Connect"
Inspector should show:
- A successful connection
- Available tools, including
retrieve_hr_policy
In the Tools tab, select retrieve_hr_policy and run a test query:
Example query:
How do I submit a leave request in Unanet?
Example JSON input:
{
"query": "How do I submit a leave request in Unanet?",
"topK": 5,
"scoreThreshold": 0.3
}You should see a JSON response with fields like:
queryhitCountresults[](one per ranked chunk)
Each result includes:
rank– 1-based rankscore– similarity score from Bedrocktext– snippet of HR contentlocation.s3Location.uri– S3 path of the source documentmetadata– includes page number, data source ID, etc.
Clients (ChatGPT, internal apps) can then generate a friendly answer and show links or citations using this information.
Query the ESI HR Bedrock Knowledge Base for HR policies, procedures, and workflows (Unanet, PTO, benefits, etc.), and return raw retrieved chunks with metadata and scores. Downstream clients can use these to generate human-friendly answers and citations.
The MCP schema is defined in src/index.ts, but logically the tool expects:
-
query(string, required)
Natural language question (e.g., "How do I submit a leave request in Unanet?") -
topK(number, optional)
Maximum number of chunks to return. Default is typically 5 if not provided. -
scoreThreshold(number, optional)
Minimum similarity score. Chunks with scores below this value may be filtered out or flagged as low-confidence.
A typical response from the tool looks like:
query– echoed user queryhitCount– number of retrieved chunksresults[]– list of ranked results; each contains:rank– rank order (1 is highest)score– relevance score from Bedrocktext– extracted text chunk from the HR documentlocation– where the text came from (S3 URI, etc.)metadata– additional keys such as:x-amz-bedrock-kb-source-urix-amz-bedrock-kb-document-page-numberx-amz-bedrock-kb-data-source-id
Clients can use location and metadata to provide "View source" links and document citations.
These components are outside this repo but are important context for developers.
- Bucket:
esi-hr-docs - Folder structure (examples):
handbook/benefits/leave-and-pto/systems-guides/state-notices/timekeeping/travel-and-expense/
New or updated documents should be uploaded into the correct subfolder in esi-hr-docs.
- Name:
esi-hr-kb-dev - ID:
OLRJAOAVCZ - Region:
us-east-1 - Data source: S3 (ID
XY5AQACOZ8) pointing ats3://esi-hr-docs/ - Embedding model: Titan Text Embeddings v2 (or equivalent)
- Vector store: Aurora PostgreSQL with pgvector
The Knowledge Base needs ingest/sync jobs to incorporate new or changed docs.
Use the AWS console: Bedrock → Knowledge Bases → esi-hr-kb-dev → Data source → "Sync"
- Lambda function:
hr-kb-scheduled-sync - Environment variables:
HR_KB_ID=OLRJAOAVCZHR_KB_DATASOURCE_ID=XY5AQACOZ8AWS_REGION=us-east-1
- Behavior:
- Calls
StartIngestionJobfor the HR KB and data source - Logs ingestion job ID, status, and basic statistics
- Calls
- EventBridge schedule:
- Rule targeting
hr-kb-scheduled-syncLambda - Schedule expression such as
rate(1 day)(can be adjusted as needed)
- Rule targeting
New or updated documents in s3://esi-hr-docs/... will be picked up and indexed after the next successful ingestion job completes.
tsconfig.jsonis configured with:target:"ES2020"module:"Node16"moduleResolution:"Node16"strict:true
npm run buildcompiles TypeScript tobuild/index.js
MCP server logs:
- Startup info (KB ID, region, AWS profile)
- Errors from Bedrock Agent Runtime calls
Lambda (hr-kb-scheduled-sync) logs:
- Ingestion-job start events
- Ingestion job ID and initial status
- Add a second tool, e.g.,
answer_hr_question, that:- Uses
RetrieveAndGenerateinstead ofRetrieve - Returns a composed natural-language answer plus citations, instead of just raw chunks
- Uses
- Add simple re-ranking / filtering rules inside
retrieve_hr_policy, such as:- Prefer
leave-and-pto/orsystems-guides/S3 prefixes for Unanet or leave-related queries
- Prefer
- Add automated tests (Jest/Vitest) to:
- Validate the MCP tool schema
- Mock Bedrock Agent Runtime and ensure payloads and result shapes are correct
- Add a "health check"/ping tool to make operational monitoring easier
- Primary owner: EAAP / AI Platform team
- Primary consumers: HR support agents and internal tools that need structured access to ESI HR content through AWS Bedrock and MCP
If any of the following change, this README and related runbooks should be updated:
- Knowledge base name/ID or region
- S3 bucket or folder structure
- MCP tool names or request/response schemas
- Sync strategy (manual vs scheduled) or Lambda/EventBridge wiring