1. Conduid
  2. IoT
  3. Bns Lang
MCP server · IoT

Bns Lang

Write PLC ladder logic with just a numpad. IEC 61131-3 DSL + MCP for Cursor.

34Low

Scored 6 months ago · breakdown

About Bns Lang

Bns Lang is an MCP server in the IoT category: write PLC ladder logic with just a numpad. IEC 61131-3 DSL + MCP for Cursor.

Install

From source
git clone https://github.com/BAESY2/bns-lang-

This server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.

Tools (4)

bns_checkSyntax validation

Parameters not published.

bns_compileBNS → IEC 61131-3 Structured Text

Parameters not published.

bns_explainExplain BNS code in natural language

Parameters not published.

bns_ladderASCII ladder diagram visualization

Parameters not published.

Ask AI

✦

Ask AI about Bns Lang

Powered by Claude · Grounded in docs

I know everything about Bns Lang. Ask me about installation, configuration, usage, or troubleshooting.

Security checks

  • ✓README presentThe repository ships documentation.

5 checks have not been run yet.

README

 ██████╗ ███╗   ██╗███████╗    ██╗      █████╗ ███╗   ██╗ ██████╗ 
 ██╔══██╗████╗  ██║██╔════╝    ██║     ██╔══██╗████╗  ██║██╔════╝ 
 ██████╔╝██╔██╗ ██║███████╗    ██║     ███████║██╔██╗ ██║██║  ███╗
 ██╔══██╗██║╚██╗██║╚════██║    ██║     ██╔══██║██║╚██╗██║██║   ██║
 ██████╔╝██║ ╚████║███████║    ███████╗██║  ██║██║ ╚████║╚██████╔╝
 ╚═════╝ ╚═╝  ╚═══╝╚══════╝    ╚══════╝╚═╝  ╚═╝╚═╝  ╚═══╝ ╚═════╝ 

Write PLC ladder logic with just a numpad.

A minimal DSL that compiles to IEC 61131-3 ladder diagrams. No IDE needed. No mouse clicking. Just type numbers → get rungs.

IEC 61131-3 PLC MCP PRs Welcome

Quick Start · Syntax · Examples · Why? · Roadmap


⚡ 3 Seconds to Understand

Traditional PLC programming requires a GUI IDE, mouse-clicking contacts onto rungs, and navigating nested menus. BNS Lang lets you type it.

         BNS Lang                          Ladder Diagram
                                     
    1 2 + 3 = 50                     ──┤ X1 ├──┤ X2 ├──┬──┤ X3 ├──── ( Y50 )
                                                        │
    1 2 | 4 = 50                     ──┤ X1 ├──┤ X2 ├──┤ X4 ├────── ( Y50 )

That's it. Numbers are I/O addresses. + is series (AND). | is parallel (OR). = is the output coil.


🚀 Quick Start

# Install
npm install -g bns-lang

# Compile a .bns file to IEC 61131-3 structured text
bns compile program.bns -o output.st

# Or pipe directly
echo "1 2 + 3 = 50" | bns compile --stdout

Create program.bns:

# Motor start/stop circuit
# START(X1) AND NOT STOP(X2) OR HOLDING(Y10) → MOTOR(Y10)
# Contact 110 = Y10 (output as contact), coil 10 = Y10

1 -2 | 110 = 10

Compile:

$ bns compile program.bns --stdout

(* Generated by BNS Lang v2.0 *)
(* Motor start/stop circuit *)

PROGRAM MAIN
VAR
  X1 AT %IX0.1 : BOOL;
  X2 AT %IX0.2 : BOOL;
  Y10 AT %QX1.10 : BOOL;
END_VAR

Y10 := ((X1 AND NOT X2) OR Y10);

END_PROGRAM

📖 Syntax

BNS Lang is designed to be typed entirely on a numpad + a few keys. The full grammar fits on a sticky note.

Contacts & Coils

BNS Meaning Ladder IEC 61131-3
1 NO contact X1 ──┤ X1 ├── X1
-1 NC contact X1 ──┤/X1 ├── NOT X1
= 50 Output coil Y50 ──( Y50 ) Y50 :=
=! 50 Set (latch) ──(S Y50) Y50 := TRUE
=/ 50 Reset (unlatch) ──(R Y50) Y50 := FALSE

Operators

BNS Meaning Description
(space) Series (AND) Contacts in series on same rung
+ Series (AND) Explicit AND (same as space)
| Parallel (OR) Branch — creates parallel path
- Negate (NOT) Prefix — normally closed contact
( ) Group Group contacts for complex logic

Special

BNS Meaning
300 5000 Timer 300, 5000ms (address 300 = T300)
C5 100 Counter C5, preset 100
# Comment (rest of line)
--- Rung separator (optional)

Address Mapping

Range Type Description
0-99 X (Input) Digital inputs
100-199 Y (Output as contact) Y0–Y99 when used as contact (e.g. 110 = Y10)
0-99 (coil) Y (Output) Digital outputs Y0–Y99
200-299 M (Internal) Internal relays
300-399 T (Timer) Timer contacts
400-499 C (Counter) Counter contacts

Address mapping is configurable per target PLC. Defaults match LS Electric XGT conventions.


📝 Examples

See the examples/ folder: 01-basics.bns, 02-self-holding.bns, 03-conveyor.bns, 04-traffic-light.bns, 05-wafer-transfer.bns.


🤔 Why BNS Lang?

  • One line. 8 characters. Zero clicks. for X1 AND X2 → Y50: 1 2 = 50
  • Version control with Git. Review in PRs. Generate from scripts. Pipe through CI/CD.
  • For PLC engineers, automation teams, educators, and AI/LLM developers.

🤖 AI Integration (Cursor / Claude Code)

BNS Lang is the first PLC language designed for AI-native development. Two ways to use it:

Option 1: Cursor Rules (zero setup)

This repo includes .cursorrules — just open the project in Cursor and start talking:

You: "컨베이어에 센서 감지되면 모터 돌리고 비상정지 누르면 멈추게 해줘"

Cursor: Here's the BNS Lang code:

# Conveyor motor control
# X1 = Sensor, X99 = E-Stop (NC), Y100 = Motor
1 -99 | 200 = 100    # Sensor AND NOT E-Stop, self-held (200 = M200)
99 =/ 100            # E-Stop resets motor

Works with any natural language → BNS Lang → IEC 61131-3 pipeline.

Option 2: MCP Server (full pipeline)

Connect BNS Lang as an MCP tool in Cursor or Claude Code:

Cursor — .cursor/mcp.json is included:

{
  "mcpServers": {
    "bns-lang": {
      "command": "node",
      "args": ["./src/mcp-server.js"]
    }
  }
}

Claude Code:

claude mcp add bns-lang node ./src/mcp-server.js

Now you get 4 tools directly in your AI coding assistant:

Tool What it does
bns_compile BNS → IEC 61131-3 Structured Text
bns_check Syntax validation
bns_ladder ASCII ladder diagram visualization
bns_explain Explain BNS code in natural language

Full workflow in Cursor/Claude Code:

You: "Create a traffic light controller with 3 phases"
AI:  [generates BNS code]
AI:  [calls bns_check → validates]
AI:  [calls bns_compile → outputs ST]
AI:  [calls bns_ladder → shows diagram]
You: "Change green phase to 7 seconds"
AI:  [modifies and recompiles]

Natural language → BNS Lang → Compile → Verify → Ladder diagram, all without leaving your editor.


🏗️ Architecture

  .bns source          Parser          IR            Code Generator       Target
 ┌──────────┐    ┌──────────────┐   ┌─────┐    ┌────────────────────┐   ┌──────────┐
 │ 1 2 = 50 │ →  │ Tokenizer →  │ → │ AST │ →  │ LS Electric XGT ST │ → │ .st file │
 └──────────┘    │ Parser       │   │     │    │ IEC 61131-3 ST     │   │ .prj     │
                 └──────────────┘   │     │    │ Ladder JSON (viz)  │   └──────────┘
                                    └─────┘    └────────────────────┘

Target PLCs

Target Status Output Format
LS Electric XGT ✅ Production Structured Text (.st)
IEC 61131-3 Generic ✅ Production Structured Text (.st)
Inovance H5U/H3U 🚧 Beta LiteST / XML (.prj)
Siemens S7 (TIA) 📋 Planned SCL
Mitsubishi MELSEC 📋 Planned Structured Text
Ladder JSON ✅ Production JSON (for visualization)

🛠️ CLI Reference

# Compile to structured text
bns compile input.bns -o output.st

# Compile with target PLC
bns compile input.bns --target xgt -o output.st
bns compile input.bns --target inovance -o output.prj

# Validate syntax only
bns check input.bns

# Output AST as JSON (for tooling/LLM integration)
bns ast input.bns --json

# Output ladder diagram as ASCII art  
bns ladder input.bns

# REPL mode
bns repl
> 1 2 = 50
──┤ X1 ├──┤ X2 ├──( Y50 )
>

📦 Project Structure

bns-lang/
├── .cursor/
│   └── mcp.json           # Cursor MCP config (ready to use)
├── .cursorrules            # Cursor AI rules for BNS Lang generation
├── .github/
│   ├── workflows/ci.yml
│   ├── FUNDING.yml
│   └── ISSUE_TEMPLATE/
├── src/
│   ├── tokenizer.js
│   ├── parser.js
│   ├── ir.js
│   ├── generators/ (st.js, xgt.js, inovance.js, ladder-json.js, ascii.js)
│   ├── mcp-server.js       # MCP server for Cursor / Claude Code
│   ├── cli.js
│   └── index.js
├── examples/
├── docs/ (SYNTAX.md, TARGETS.md, LLM-GUIDE.md)
├── tests/
├── package.json
├── LICENSE
└── README.md

🗺️ Roadmap

  • Core parser & tokenizer
  • IEC 61131-3 Structured Text output
  • LS Electric XGT target
  • ASCII ladder diagram output
  • CLI tool
  • Timer/Counter support
  • Cursor Rules (.cursorrules)
  • MCP Server (Cursor / Claude Code integration)
  • Inovance H5U/H3U target (beta)
  • Siemens S7 SCL target
  • Function Block (FB) support
  • bns fmt — auto-formatter
  • bns sim — offline logic simulator
  • VS Code extension with syntax highlighting
  • Web playground (try BNS Lang in browser)
  • PLAIDE deep integration

🤝 Contributing

Contributions are welcome! See CONTRIBUTING.md for guidelines.

git clone https://github.com/BAESY2/bns-lang.git
cd bns-lang
npm install
npm test

Good First Issues

  • Add syntax highlighting for more editors
  • Write examples for common PLC patterns
  • Add a new target PLC code generator
  • Improve error messages

📄 License

MIT — Use it in your commercial PLC projects. No strings attached.


BNS Lang is part of the ZENION industrial automation ecosystem.

Industrial automation deserves modern developer tooling.

README copy captured when this server was indexed; it may lag the repository. The original is authoritative.

Questions

About Bns Lang

How do I install Bns Lang?

No package has been published for this server, so install it from source: clone the repository and follow its README.

Is Bns Lang safe to use with an AI agent?

Its trust score is 34 out of 100 (low). It passes 1 of the 1 static security checks run so far. It has no ConduID identity yet, so agent calls to it are not receipted.

Is Bns Lang still maintained?

Conduid hasn't recorded a commit date for this repository yet. Check the repository directly for recent activity.