aburmd/aws-nasmatchstockprofile-mcp
If you are the rightful owner of aws-nasmatchstockprofile-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Model Context Protocol (MCP) server is designed to facilitate seamless integration and automation of workflows by leveraging AI agents to manage infrastructure and runtime code.
Welcome to your CDK TypeScript project
This is a blank project for CDK development with TypeScript.
The cdk.json file tells the CDK Toolkit how to execute your app.
Useful commands
npm run buildcompile typescript to jsnpm run watchwatch for changes and compilenpm run testperform the jest unit testsnpx cdk deploydeploy this stack to your default AWS account/regionnpx cdk diffcompare deployed stack with current statenpx cdk synthemits the synthesized CloudFormation template
aws-nasmatchstockprofile-mcp/ │── cdk/ # AWS CDK Infrastructure (TypeScript) │ ├── bin/ │ │ └── aws-nasmatchstockprofile-mcp.ts # CDK entry point │ ├── lib/ │ │ └── aws-nasmatchstockprofile-mcp-stack.ts # Main stack │ ├── package.json │ ├── cdk.json │ └── tsconfig.json │ │── src/ # Python Runtime (MCP + AI Agent) │ ├── mcp_server/ │ │ ├── init.py │ │ ├── main.py # MCP server entry │ │ ├── excel_handler.py # Logic for Excel updates │ │ ├── data_extractor.py # Logic for parsing website Excel │ │ └── config.py # Configurations (e.g. S3 bucket, env vars) │ │ │ ├── agent/ │ │ ├── init.py │ │ ├── orchestrator.py # AI agent orchestration │ │ └── prompts.py # System prompts, reasoning templates │ │ │ ├── tests/ │ │ └── test_excel_handler.py │ │ │ └── requirements.txt │ │── .gitignore │── README.md
git remote set-url origin https://aburmd@github.com/aburmd/aws-nasmatchstockprofile-mcp.git
ssh-keygen -t ed25519 -C "aburmd@gmail.com"
cat ~/.ssh/id_ed25519.pub
Copy the output → Go to GitHub → Settings → SSH and GPG keys → New SSH key → Paste.
git remote remove origin git remote add origin git@github.com:aburmd/aws-nasmatchstockprofile-mcp.git
ssh -T git@github.com
You should see: "Hi aburmd! You've successfully authenticated."
git push -u origin main
Here’s a single, copy-pasteable master prompt you can give to your code assistant to scaffold the entire repo. It bakes in every requirement: CDK in TypeScript, all runtime in Python, API Gateway WebSocket for MCP-style tools, and Step Functions + ECS Fargate for ETL.
🔧 MASTER PROMPT (copy–paste below this line)
You are an expert AWS/CDK solution engineer and senior Python backend developer. Generate a production-ready Git repository that implements the following, with all Infrastructure as Code in TypeScript (CDK v2) and all runtime code in Python 3.11.
High-Level Goal
-
Build an MCP-style tool endpoint over API Gateway WebSocket so any AI agent can call tools like:
mapping.propose(Bedrock → Claude; column mapping with confidences)mapping.apply(DynamoDB upserts)excel.replace_table(S3 + openpyxl; writes a table into a target sheet of an Excel template)
-
Build a daily deterministic ETL that:
- Reads
raw/source.xlsxfrom S3 - Normalizes to CSV/Parquet (
staging/) - Publishes a curated
master.xlsxtocurated/using an Excel template
- Reads
-
Orchestration via Step Functions running an ECS Fargate task (Python container) for heavy ETL steps.
-
All configs/versioned artifacts live in S3 (
config/,raw/,staging/,curated/).
Repository Layout (create these paths & files)
aws-excel-mcp/
README.md
.gitignore
package.json
cdk.json
tsconfig.json
bin/app.ts
lib/
kms-stack.ts
storage-stack.ts
ecr-stack.ts
network-stack.ts
ecs-runner-stack.ts
ws-mcp-stack.ts
stepfn-stack.ts
events-stack.ts
containers/
excel-runner/
Dockerfile
app/handler.py
runtime/
mcp_router/handler.py
mapping_propose/handler.py
mapping_apply/handler.py
excel_replace/
handler.py
requirements.txt
s3_bootstrap/config/
mapping.yaml
master_template.xlsx # put a placeholder binary or describe in README to upload
.github/workflows/cdk-deploy.yml
Core Requirements
Infrastructure (CDK TypeScript)
-
KMS CMK (
alias/excel-pipeline-kms) for S3 + DynamoDB encryption. -
S3 bucket (versioned, KMS-encrypted) with prefixes:
raw/,staging/,curated/,config/. -
DynamoDB:
MappingOverrides(PKdataset_idSTRING, SKsource_colSTRING).WsConnections(PKconnection_idSTRING) for WebSocket connection management.
-
API Gateway WebSocket:
- Stage
prod, routes:$connect,$disconnect,$default, plus explicit routesmapping.propose,mapping.apply,excel.replace_table. - Router Lambda (Python) handles connect/disconnect/default and dispatches to tool Lambdas; responds over
@connectionsAPI.
- Stage
-
Tool Lambdas (Python):
mapping_propose: calls Amazon Bedrock (Claude 3.5 Sonnet model idanthropic.claude-3-5-sonnet-20240620-v1:0). Input:source_cols[],canonical_cols[]. Output: JSON array[{from,to,confidence}]. Return strict JSON only.mapping_apply: upserts items intoMappingOverrides.excel_replace: loadsconfig/master_template.xlsxfrom S3, writes tabular data to givensheet/start_cellwith openpyxl, and saves tocurated/master.xlsx.
-
VPC with public + private subnets; VPC endpoints for S3 (Gateway) and Bedrock Runtime (Interface).
-
ECR repository for the ETL container:
excel-runner. -
ECS Fargate:
- Cluster + TaskDefinition (1 vCPU/2GB) to run
containers/excel-runner.
- Cluster + TaskDefinition (1 vCPU/2GB) to run
-
Step Functions state machine:
Transform→ run ECS task with args to readraw/source.xlsx, normalize tostaging/orders.parquet+staging/orders.csv.ProposeMapping→ callmapping_proposeLambda.ApplyMapping→ callmapping_applyLambda.Publish→ run ECS task to create/overwritestaging/master_draft.xlsxand promote tocurated/master.xlsxvia template.
-
EventBridge schedule: daily 06:05 AM PT (cron hour 13 UTC), triggers the state machine.
-
IAM least privilege:
- Router:
execute-api:ManageConnections,lambda:InvokeFunctionfor tool Lambdas, RW onWsConnections. - Tool Lambdas: scoped S3, DDB; Bedrock invoke for mapping_propose.
- ECS task role: scoped S3 RW.
- Router:
-
Use
@aws-cdk/aws-apigatewayv2-alphaand@aws-cdk/aws-apigatewayv2-integrations-alphafor WebSocket + Lambda integration. -
Use
@aws-cdk/aws-lambda-python-alphaPythonFunctionto bundle Python Lambdas andrequirements.txtforexcel_replace.
Runtime Code (Python 3.11)
-
Router Lambda:
- On
$connect: storeconnection_idin DDB, send handshake JSON{ "mcp": "hello", "tools": ["mapping.propose","mapping.apply","excel.replace_table"] }. - On
$disconnect: deleteconnection_id. - On
$defaultor explicit tool route: parse body JSON; figure out tool name (either routeKey orbody.tool); invoke the right tool Lambda synchronously; respond to client with{ ok: true, tool, result }.
- On
-
mapping_propose Lambda:
- Prompt template to strictly return JSON array; parse LLM output robustly; if parse fails, return
[].
- Prompt template to strictly return JSON array; parse LLM output robustly; if parse fails, return
-
mapping_apply Lambda:
- Input:
{ "dataset_id": "orders_v1", "mapping": [{from,to,confidence}] }. Upsert to DDB; return count.
- Input:
-
excel_replace Lambda:
- Input:
{template_key, out_key, sheet, start_cell, data:[{...}]}. - Use openpyxl to clear a reasonable range, write headers + rows, save to S3.
- Input:
-
ECS runner container (
excel-runner):- CLI with
--op transformand--op publish. transform: read Excel fromraw/, applymapping.yamlrules (rename/dtypes/filters/dedupe), write Parquet + CSV tostaging/.publish: read CSV + template from S3, write to target sheet/cell, put draft tostaging/master_draft.xlsxand final tocurated/master.xlsx.
- CLI with
Config Files
-
s3_bootstrap/config/mapping.yaml(sample):dataset_id: "orders_v1" source: sheet: "Export_Orders" sheets: - name: "Export_Orders" rename: "Order Id": order_id "Customer Name": customer "Order Date": order_date "Total": total_amount dtypes: order_date: datetime total_amount: float dedupe_keys: [order_id] targets: - sheet: "Raw_Orders" mode: replace_table ai: min_confidence_auto_apply: 0.85 -
Put a placeholder
master_template.xlsx(or document that the user should upload theirs).
Dockerfile (Python)
containers/excel-runner/Dockerfile: based onpython:3.11-slim; installpandas,openpyxl,pyarrow,boto3,pyyaml.
GitHub Actions (optional)
cdk-deploy.ymlthat builds CDK, synthesizes, and deploys (OIDC role assumed via secrets).
Non-Functional Requirements
- Clear, defensive error handling (no crashes on malformed JSON or empty datasets).
- Logging with useful context: request IDs, S3 keys, row counts, confidence stats.
- Idempotent publishes (only promote to
curated/after successful run). - Versioning: rely on S3 versioning for rollbacks.
- Security: least-privilege IAM, KMS at rest, private VPC traffic to Bedrock/S3 where possible.
README.md (include)
-
High-level architecture diagram (ASCII ok).
-
Setup steps:
npm install,cdk bootstrapcdk deploy Kms Storage Ecr Net- Build & push
excel-runnerimage to ECR cdk deploy EcsRunner WsMcp StepFn Events- Upload
s3_bootstrap/config/*and a sampleraw/source.xlsx
-
How to test WebSocket with
wscat:wscat -c wss://<api-id>.execute-api.<region>.amazonaws.com/prod > {"tool":"mapping.propose","source_cols":["Order Id","Cust Name"],"canonical_cols":["order_id","customer"]} -
How to start a manual Step Functions execution and where outputs land in S3.
-
Cost notes (API GW WS pay-per-message; no ALB).
Acceptance Criteria
cdk synthandcdk deploysucceed with no manual edits beyond region/account.- WebSocket connection succeeds;
$connectreturns tool list; callingmapping.proposereturns a JSON array (mockable if Bedrock isn’t enabled). - Running the state machine processes a sample
raw/source.xlsxintostaging/*.parquet/.csvand publishescurated/master.xlsx. excel.replace_tablewrites to a hidden or staging sheet without corrupting formulas in the template (document that the visible sheets referenceRaw_Orders).- IAM policies are restricted to necessary resources only.
Coding Standards
- Python: 3.11, type hints where reasonable, small functions, explicit returns, PEP8.
- CDK TS: clear stack boundaries, export key ARNs/URLs via stack class properties, no hardcoded ARNs.
- Use environment variables for Bucket name, DDB table, Model ID.
- Tool Lambdas return strict JSON; router always wraps in
{ok, tool, result}.
Bonus (if time allows)
- Add a
sfn.starttool (Lambda) so agents can kick the batch via WebSocket. - Step Functions choice state to require human approval if any mapping confidence < 0.85.
- API GW authorizer (Cognito or IAM) for WebSocket.
Deliverables: fully generated repo tree with all files populated per above, ready to commit and deploy. Do not omit any file listed. Print the final repository tree and any post-deploy instructions at the end.
🔧 END MASTER PROMPT
Want me to tailor the sample mapping.yaml to your exact column names? If you share a dummy source.xlsx header row and target sheet name, I’ll plug them in.
mkdir aws-nasmatchstockprofile-mcp cd aws-nasmatchstockprofile-mcp
Initialize CDK with TypeScript
cdk init app --language typescript
install cdk
node -v npm -v
If not installed, grab it via Node.js official site or Homebrew: brew install node
npm install -g aws-cdk
cdk bootstrap aws://654654547262/us-east-1 cdk deploy
npm run build
Deploy core data plane first
cdk deploy BaseInfra
Deploy networking + ECS runner
cdk deploy Net EcsRunner
Deploy WebSocket + Lambdas
cdk deploy WsMcp
Deploy Step Functions + schedule
cdk deploy StepFn Events
Got it 👍 — let’s walk through step by step so you can learn how to approach this with MCP (Model Context Protocol) and AWS CDK.
We’ll treat this as:
- Business Requirement → Update Excel based on another Excel.
- Architecture → AWS cost-effective, scalable, Git-based infra.
- MCP Role → Automate infra + runtime workflows via AI agent.
- Step-by-Step CDK Build → Start small (base stack), then extend.
1. Business Requirement
- You have Excel File A (source) and Excel File B (target).
- The system should update B based on values from A (rules defined by you).
- This must be automated, repeatable, and cloud-based.
2. Architecture (AWS Components)
- S3 → Store input & output Excel files.
- Lambda (Python runtime) → Process Excel updates (using
openpyxlorpandas). - EventBridge / S3 Trigger → Kick off processing when new file uploaded.
- IAM Roles → Secure access.
- (Optional) Step Functions if workflow grows complex.
This is all CDK-driven, deployed via Git.
3. Role of MCP (Model Context Protocol)
-
MCP allows you to define actions for AI agents (like me) to orchestrate infra and runtime code.
-
Example:
- Define a tool in MCP for "Deploy CDK stack".
- Define another for "Process Excel".
-
Then your AI agent can decide autonomously: upload file → trigger Lambda → update Excel → store output → notify you.
So MCP is the glue to:
- Describe capabilities (e.g., "Excel Processor").
- Expose them to AI agent (so it knows it can invoke CDK/Lambda).
- Automate workflows (instead of you clicking manually).
4. Step-by-Step CDK Build Plan
Here’s how we’ll build incrementally:
Step 1: Base Stack
- VPC (if needed), S3 bucket(s).
- IAM roles & policies.
- Output: "We can upload Excel files."
Step 2: Lambda Runtime
- Python code (using
openpyxl) packaged & deployed. - Connected to S3.
- Output: "Lambda runs when file uploaded."
Step 3: Event Trigger
- Configure S3 → EventBridge → Lambda.
- Output: "Automation kicks off on upload."
Step 4: Excel Processing Logic
- Lambda reads
fileA.xlsx&fileB.xlsx, applies rules, writes back to S3. - Output: "Excel files updated automatically."
Step 5: MCP Exposure
- Define MCP tool(s) → “Upload Excel”, “Run Processor”, “Deploy Stack”.
- Output: "AI agent can handle Excel updates end-to-end."
💡 Cost:
- S3 = pennies per GB.
- Lambda = free tier + $0.20 per 1M requests.
- EventBridge = $1 per 1M events.
- IAM roles = free. 👉 Essentially close to $0 monthly unless you process huge Excel files.
Do you want me to start with Step 1 (Base Stack CDK code) and explain the CDK resources we’ll add before we write the code?
aws-nasmatchstockprofile-mcp
Foundational CDK app for an MCP-controlled, cost-effective Excel processing pipeline on AWS.
Step 1 (this repo state)
- KMS CMK (alias:
alias/excel-pipeline-kms) - S3 bucket (versioned, KMS-encrypted)
- DynamoDB tables:
MappingOverrides(PK: dataset_id, SK: source_col)WsConnections(PK: connection_id)
Install & Deploy
# from repo root
npm install
npm run build
npm run synth
npm run deploy -- BaseInfra
# after step4
aws-nasmatchstockprofile-mcp/
bin/app.ts
lib/base-infra.ts # add WebSocket API + permissions here
lambda/
processor/ # (already from step2/3)
handler.py
requirements.txt
wsmcp/
on_connect.py
on_disconnect.py
on_message.py
requirements.txt
Got it 👍 — let’s walk through step by step so you can learn how to approach this with MCP (Model Context Protocol) and AWS CDK.
We’ll treat this as:
Business Requirement → Update Excel based on another Excel.
Architecture → AWS cost-effective, scalable, Git-based infra.
MCP Role → Automate infra + runtime workflows via AI agent.
Step-by-Step CDK Build → Start small (base stack), then extend.
1. Business Requirement
You have Excel File A (source) and Excel File B (target).
The system should update B based on values from A (rules defined by you).
This must be automated, repeatable, and cloud-based.
2. Architecture (AWS Components)
S3 → Store input & output Excel files.
Lambda (Python runtime) → Process Excel updates (using openpyxl or pandas).
EventBridge / S3 Trigger → Kick off processing when new file uploaded.
IAM Roles → Secure access.
(Optional) Step Functions if workflow grows complex.
This is all CDK-driven, deployed via Git.
3. Role of MCP (Model Context Protocol)
MCP allows you to define actions for AI agents (like me) to orchestrate infra and runtime code.
Example:
Define a tool in MCP for "Deploy CDK stack".
Define another for "Process Excel".
Then your AI agent can decide autonomously: upload file → trigger Lambda → update Excel → store output → notify you.
So MCP is the glue to:
Describe capabilities (e.g., "Excel Processor").
Expose them to AI agent (so it knows it can invoke CDK/Lambda).
Automate workflows (instead of you clicking manually).
4. Step-by-Step CDK Build Plan
Here’s how we’ll build incrementally:
Step 1: Base Stack
VPC (if needed), S3 bucket(s).
IAM roles & policies.
Output: "We can upload Excel files."
Step 2: Lambda Runtime
Python code (using openpyxl) packaged & deployed.
Connected to S3.
Output: "Lambda runs when file uploaded."
Step 3: Event Trigger
Configure S3 → EventBridge → Lambda.
Output: "Automation kicks off on upload."
Step 4: Excel Processing Logic
Lambda reads fileA.xlsx & fileB.xlsx, applies rules, writes back to S3.
Output: "Excel files updated automatically."
Step 5: MCP Exposure
Define MCP tool(s) → “Upload Excel”, “Run Processor”, “Deploy Stack”.
Output: "AI agent can handle Excel updates end-to-end."
💡 Cost:
S3 = pennies per GB.
Lambda = free tier + $0.20 per 1M requests.
EventBridge = $1 per 1M events.
IAM roles = free.
👉 Essentially close to $0 monthly unless you process huge Excel files.
aws lambda invoke --function-name BaseInfra-ExcelProcessorFnB7B43EA3-fRqa6Yu3FXTU \
--payload '{
"source_key":"source/Portfolio_Positions_Aug-21-2025.csv",
"target_key":"source/nasmatch-portfolio.xlsx",
"output_key":"output/nasmatch-portfolio-updated.xlsx"
}' \
/tmp/out.json && cat /tmp/out.json
# make sure the template exists
aws s3 cp ~/Downloads/nasmatch-portfolio.xlsx s3://baseinfra-excelbucket52f10cb5-wwsunmtzl4nc/source/nasmatch-portfolio.xlsx
# upload CSV (should auto-trigger lambda)
aws s3 cp ~/Downloads/Portfolio_Positions_Aug-21-2025.csv s3://baseinfra-excelbucket52f10cb5-wwsunmtzl4nc/source/Portfolio_Positions_Aug-21-2025.csv
aws s3 cp data/positions-2025-08-23.csv s3://baseinfra-excelbucket52f10cb5-wwsunmtzl4nc/source/positions-2025-08-23.csv
# watch logs
aws logs tail /aws/lambda/BaseInfra-ExcelProcessorFnB7B43EA3-fRqa6Yu3FXTU --follow
# verify output
aws s3 cp s3://baseinfra-excelbucket52f10cb5-wwsunmtzl4nc/output/nasmatch-portfolio-updated.xlsx ./nasmatch-portfolio-updated.xlsx