Skip to content

rvalavan/finacle_script_agent

Repository files navigation

Finacle Script Agent — Knowledge Base

An AI-powered knowledge base and developer agent for the Infosys Finacle Core Banking scripting language. Enables developers to write correct Finacle Script using Claude Code as an AI pair programmer grounded in verified KB data.


What This Project Does

Finacle Script is a proprietary 4GL language used to customize Infosys Finacle Core Banking. It has hundreds of built-in hooks, a large database schema, and strict language rules that are poorly documented for AI tools.

This project builds a structured KB that exposes all of that knowledge to Claude Code via an MCP server, so developers can:

  • Describe what they need in plain English → get the right hook or table
  • Generate Finacle scripts grounded in real KB data, not hallucinated APIs
  • Understand the blast radius of any change before making it
  • Work consistently across a team with shared coding standards

Architecture

finacle_script_agent/
│
├── dev_guildeline/          # Language reference docs (19 files)
│   ├── control_statements.md
│   ├── sql_select_stmt.md
│   ├── cursor_select.md
│   ├── error_handling.md
│   └── ...
│
├── user-hook/               # User hook documentation (250 files)
│   ├── urhk-b2k-valdate.md
│   ├── urhk-dbcursoropenwithbind.md
│   ├── urhk-setorbout.md
│   └── yet-to-gain-knowledge.md   ← gap tracker
│
├── data-dictionary/         # Finacle DB table docs (1,079 files)
│   ├── general-acct-mast-table.md  (GAM)
│   ├── hist-tran-dtl-table.md      (HTD)
│   └── yet-to-gain-knowledge.md   ← gap tracker
│
├── loaders/                 # Data pipeline scripts
│   ├── build_dependency_graph.py  ← Neo4j graph loader
│   ├── sqlite_loader.py           ← SQLite KB loader
│   └── qdrant_loader.py           ← Vector embeddings loader
│
├── mcp_server/              # MCP server (Claude Code connects here)
│   ├── server.py            ← 9 MCP tools over HTTP/SSE
│   ├── kb/                  ← SQLite DB (generated, not in repo)
│   └── personas/
│       ├── developer.md            ← Developer persona standards
│       └── developer_claude.md     ← CLAUDE.md template for dev projects
│
├── icici/                   # Sample spec + BR files
├── SPEC.md                  # Full system architecture spec
├── finacle-kb-todo.md       # Work tracker
└── claude-conversation.md   # Session history reference

Data Stores

Store Purpose Port
SQLite (mcp_server/kb/finacle_kb.db) Exact lookups — hooks by function name, tables by synonym Local file
Neo4j Script dependency graph — impact analysis, call chains 7687
Qdrant Semantic vector search — plain English → hook/table 6333
Ollama Local embedding model (nomic-embed-text, 768d) 11434

What Has Been Built

KB Content

Area Status Count
Language reference docs Complete 19 files
User hook docs (stable) 35 done, 215 stubs 250 total
Data dictionary tables 1,079 parsed from PDF 425 still missing
Script dependency graph Complete 3,741 scripts, 537 tables, 295 hooks

Infrastructure

Component Status
Neo4j dependency graph loader (build_dependency_graph.py) Complete + watch mode
SQLite KB loader (sqlite_loader.py) Complete
Qdrant vector loader (qdrant_loader.py) Complete
MCP server — 9 tools over SSE (server.py) Complete
Developer persona + CLAUDE.md template Complete

MCP Tools Available

Tool Description
get_hook(function_name) Full hook doc — signature, params, patterns
get_table(table_name) Table columns and usage by name or synonym
get_guideline(topic) Language construct documentation
search_kb(query, category?) Semantic search — plain English to KB entry
impact_analysis(name, node_type) Blast radius if table/hook/script changes
find_callers(script_name) Who calls this script
find_call_chain(script_name) Full call tree from a script
get_persona(name) Load developer standards and rules
get_claude_md(name) CLAUDE.md template for new developer projects

Prerequisites

# Python packages
pip install mcp neo4j pyyaml qdrant-client ollama watchdog

# Services
# Neo4j  — install from https://neo4j.com/download/  (bolt://localhost:7687, neo4j/password)
# Qdrant — install from https://qdrant.tech/documentation/quick-start/  (http://localhost:6333)
# Ollama — install from https://ollama.com/download  (http://localhost:11434)
ollama pull nomic-embed-text

Setup & Run (Server Operator)

Run these once after cloning, then keep the MCP server running for developers.

# 1. Clone
git clone https://github.com/rvalavan/finacle_script_agent
cd finacle_script_agent

# 2. Build SQLite KB (not stored in repo)
python loaders/sqlite_loader.py

# 3. Load Neo4j dependency graph
#    Point --scr-dir at your Finacle script corpus
python loaders/build_dependency_graph.py --scr-dir "C:/path/to/finacle/scr"

# 4. Load Qdrant embeddings
python loaders/qdrant_loader.py

# 5. Start MCP server
#    Use --host 0.0.0.0 when running on a VM for team access
python mcp_server/server.py --host 127.0.0.1 --port 8765

Watch mode (auto-reload on script changes)

python loaders/build_dependency_graph.py --watch

Developer Project Setup

Each developer creates a project folder and connects to the running MCP server.

# 1. Create project folder (outside this repo)
mkdir c:\projects\my-feature
cd c:\projects\my-feature
git init

# 2. Create .mcp.json
echo '{"mcpServers":{"finacle-kb":{"type":"sse","url":"http://<server-ip>:8765/sse"}}}' > .mcp.json

# 3. Open in VS Code
code .

In Claude Code, type:

"Initialize this as a Finacle developer project"

Claude Code calls get_claude_md("developer"), writes CLAUDE.md and .claudeignore to the project. Start a new session — the developer persona loads automatically every time.

Then give Claude Code a spec file:

"Build a Finacle script based on specs/my-feature_spec.md"


Enhancing the KB — What Needs Work

See finacle-kb-todo.md for the full tracker. Priority areas for the AI engineering team:


Area 1 — KB Content (Highest Impact)

1.1 User Hook Documentation (184 stubs remaining)

Each stub in user-hook/ needs to be filled with real usage patterns sourced from the script corpus.

How to contribute:

  1. Pick a hook from user-hook/yet-to-gain-knowledge.md
  2. Search the script corpus for real usage: grep -r "urhk_FunctionName" /path/to/scr/
  3. Extract patterns — how is it called? What are the inputs/outputs? What errors are common?
  4. Fill the stub MD file following the structure of a stable doc (e.g. urhk-b2k-valdate.md)
  5. Change status: draftstatus: stable in frontmatter
  6. Run python loaders/sqlite_loader.py and python loaders/qdrant_loader.py to refresh

Priority hooks (most used, stubs exist):

  • urhk_TBAF_ShowUserException — companion to PutUserException (141 scripts)
  • urhk_ExecSRVNoCommit — service call without commit
  • urhk_facValidateUser — user authorization check

1.2 Dev Guideline Docs (17 topics missing)

Missing topics in dev_guildeline/:

Topic File to create
MTTS transaction scripting pattern mtts_pattern.md
SRV service layer scripting srv_pattern.md
ORB response building (SetOrbOut/Err/Warning) orb_response.md
Batch job lifecycle (BOD/EOD/BJS) batch_lifecycle.md
File I/O (fileOpen → read/write → fileClose) file_io.md
GOSUB subroutine pattern gosub_pattern.md
Built-in date arithmetic (SYSDATE, TODAY) date_arithmetic.md
STR$ / VAL — type conversion str_val.md
CERR structured error propagation cerr_pattern.md

Follow the frontmatter schema in any existing guideline file.

1.3 Data Dictionary (425 tables missing)

Top priority tables by script usage:

Table Synonym Scripts Module
TBAADM TBA 76 Treasury
ICI_GBM_CHALLAN_MASTER 51 Challan
WLCKM 51 Workflow Lien
CLMT 50 Clearing

Source from the Finacle Data Dictionary PDF. Use loaders/parse_data_dictionary.py as a starting point.


Area 4 — Spec Generation Pipeline

Automate generating spec files for existing scripts using Claude API + KB context.

File to create: loaders/generate_script_specs.py

What it should do:

  1. Read a .scr file
  2. Query the KB for each hook and table it uses
  3. Call Claude API with the script + KB context
  4. Output specs/<module>/<script>_spec.md (business spec) and _br.md (business rules)
  5. Skip scripts that already have a spec

Reference: icici/acm_CFR_Validation_spec.md is a hand-written example of the target output.


Area 6 — Three Personas

Beyond the developer persona, two more are planned:

Persona Files to create Tools to add
Trainer personas/trainer.md, trainer_claude.md explain, show_example, quiz
BA & Tester personas/ba.md, ba_claude.md get_br, generate_br, generate_tests

Add each persona's tools to mcp_server/server.py and its text blob to mcp_server/personas/.


Area 7 — KB Feedback Loop

File to create: loaders/kb_feedback_loop.py

When a developer writes or modifies a .scr file:

  1. Re-parse with build_dependency_graph.py (watch mode already handles this)
  2. Extract new patterns → candidate for patterns/ docs
  3. Re-embed changed files in Qdrant
  4. Update Neo4j Script node + relationships

Area 8 — Schema Validation

File to create: loaders/utils/validate_docs.py

Validates frontmatter in all MD files against JSON schemas in schemas/. Ensures id, title, category, status, tags, version are always present and correctly typed.


Frontmatter Schema Reference

Every KB document must have this YAML frontmatter:

---
id: unique-kebab-case-id
title: Human Readable Title
category: user-hook | data-dictionary | language
function: urhk_FunctionName    # hooks only
synonym: TABLE_ALIAS            # tables only
module: ACCT | GL | TM | ...
tags: [tag1, tag2]
version: "11.x"
status: stable | draft
related: [other-doc-id]
---

Code blocks must use ```finacle language tag.


Key Files for Contributors

File Read this to understand
SPEC.md Full system architecture and design decisions
CLAUDE.md How Claude Code is configured to work in this repo
finacle-kb-todo.md What's done and what's next (area-by-area)
claude-conversation.md Full build session history with decisions and patterns
user-hook/urhk-b2k-valdate.md Example of a well-written stable hook doc
dev_guildeline/cursor_select.md Example of a well-written guideline doc
icici/acm_CFR_Validation_spec.md Example of a script spec (target for Area 4)

Environment Variables

Variable Default Purpose
NEO4J_URI bolt://localhost:7687 Neo4j connection
NEO4J_USER neo4j Neo4j username
NEO4J_PASSWORD password Neo4j password
QDRANT_URL http://localhost:6333 Qdrant connection
MCP_HOST 127.0.0.1 MCP server bind host
MCP_PORT 8765 MCP server port

Defaults are hardcoded in each loader/server file and can be overridden via CLI args.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors