Context7
ส่งคู่มือการใช้ไลบรารีและเฟรมเวิร์กรุ่นล่าสุดให้ AI อ่านก่อนตอบ ช่วยให้โค้ดที่ AI เขียนไม่ใช้คำสั่งเก่าที่เลิกใช้แล้ว
คำอธิบายจากผู้ทำ (ภาษาอังกฤษตามต้นฉบับ)
Gates an LLM agent's writes to an OPC UA server on ranges, rate of change and live interlocks.
สามเรื่องนี้ไม่รวมเป็นคะแนนเดียว เพราะความเห็น การวัด และความนิยม เป็นคนละเรื่องกัน
ตัวนี้ยังไม่ได้เรียบเรียงเป็นภาษาไทย ด้านล่างคือข้อเท็จจริงที่เราอ่านจาก registry
เลือกโปรแกรม AI ที่คุณใช้ แล้วคัดลอกค่าตั้งไปวาง
OTGATE_BACKEND, OTGATE_POLICY, OTGATE_AUDIT, OTGATE_SHADOW, OTGATE_RATE_HISTORY, OTGATE_OPCUA_ENDPOINTต้องเตรียมก่อน
คุณใช้แอปไหน
เลือกแอปด้านบน เราจำไว้ให้ ครั้งหน้าปุ่มจะขึ้นว่า “ติดตั้งลง …”
เปิด Claude Desktop → Settings → Developer → Edit Config แล้ววางค่านี้ในไฟล์ claude_desktop_config.json
{
"mcpServers": {
"otgate-opcua": {
"command": "uvx",
"args": [
"otgate"
],
"env": {
"OTGATE_BACKEND": "ใส่ค่าของคุณ",
"OTGATE_POLICY": "ใส่ค่าของคุณ",
"OTGATE_AUDIT": "ใส่ค่าของคุณ",
"OTGATE_SHADOW": "ใส่ค่าของคุณ",
"OTGATE_RATE_HISTORY": "ใส่ค่าของคุณ",
"OTGATE_OPCUA_ENDPOINT": "ใส่ค่าของคุณ"
}
}
}
}พิมพ์คำสั่งนี้ใน Terminal
claude mcp add otgate-opcua --env OTGATE_BACKEND='ใส่ค่าของคุณ' --env OTGATE_POLICY='ใส่ค่าของคุณ' --env OTGATE_AUDIT='ใส่ค่าของคุณ' --env OTGATE_SHADOW='ใส่ค่าของคุณ' --env OTGATE_RATE_HISTORY='ใส่ค่าของคุณ' --env OTGATE_OPCUA_ENDPOINT='ใส่ค่าของคุณ' -- uvx otgateเติมค่าที่เว้นว่างไว้ก่อนรัน
วางในไฟล์ .cursor/mcp.json ของโปรเจกต์ หรือ ~/.cursor/mcp.json
{
"mcpServers": {
"otgate-opcua": {
"command": "uvx",
"args": [
"otgate"
],
"env": {
"OTGATE_BACKEND": "ใส่ค่าของคุณ",
"OTGATE_POLICY": "ใส่ค่าของคุณ",
"OTGATE_AUDIT": "ใส่ค่าของคุณ",
"OTGATE_SHADOW": "ใส่ค่าของคุณ",
"OTGATE_RATE_HISTORY": "ใส่ค่าของคุณ",
"OTGATE_OPCUA_ENDPOINT": "ใส่ค่าของคุณ"
}
}
}
}เบราว์เซอร์จะถามก่อนเปิดแอป จากนั้นแอปแสดงค่าตั้งให้ตรวจแล้วกดยืนยัน ช่อง key เว้นว่างไว้ให้คุณใส่เอง
วางในไฟล์ .vscode/mcp.json ของโปรเจกต์
{
"servers": {
"otgate-opcua": {
"type": "stdio",
"command": "uvx",
"args": [
"otgate"
],
"env": {
"OTGATE_BACKEND": "ใส่ค่าของคุณ",
"OTGATE_POLICY": "ใส่ค่าของคุณ",
"OTGATE_AUDIT": "ใส่ค่าของคุณ",
"OTGATE_SHADOW": "ใส่ค่าของคุณ",
"OTGATE_RATE_HISTORY": "ใส่ค่าของคุณ",
"OTGATE_OPCUA_ENDPOINT": "ใส่ค่าของคุณ"
}
}
}
}เบราว์เซอร์จะถามก่อนเปิดแอป จากนั้นแอปแสดงค่าตั้งให้ตรวจแล้วกดยืนยัน ช่อง key เว้นว่างไว้ให้คุณใส่เอง
ตัวนี้รันในเครื่องคุณ แต่ ChatGPT ต่อได้เฉพาะ server บนอินเทอร์เน็ต ลองเลือกแอปอื่น
ตัวเลือกเก็บในคุกกี้บนเครื่องนี้ ไม่ต้องมีบัญชี
OTGATE_BACKEND envOTGATE_POLICY envOTGATE_AUDIT envOTGATE_SHADOW envOTGATE_RATE_HISTORY envOTGATE_OPCUA_ENDPOINT envค่าตั้งนี้สร้างจากข้อมูลใน registry ของผู้ทำ ถ้าไม่ตรงกับ README ให้เชื่อ README
รันในเครื่องคุณ รายการเครื่องมือจะขึ้นในแอป AI หลังติดตั้ง
เราตรวจจากข้อมูลที่ใครก็เปิดดูได้ ยังไม่ได้อ่านโค้ด ข้อที่ไม่เกี่ยวกับตัวนี้ไม่นับในตัวหาร · ตรวจเมื่อ 8 พ.ย. 2569
ชื่อใน registry ยืนยันด้วยบัญชี GitHub alikup-ai ซึ่งเป็นเจ้าของ repo
ยังไม่ได้อ่านข้อมูล repo จาก GitHub
ยังไม่ได้อ่านข้อมูล repo จาก GitHub
ตัวนี้รันบนเครื่องคุณ ไม่มี endpoint บนอินเทอร์เน็ต
ตัวนี้รันบนเครื่อง ใช้ค่าที่ตั้งในเครื่องแทน
รันในเครื่องคุณ เราอ่านรายการเครื่องมือได้เฉพาะตัวที่มี endpoint บนอินเทอร์เน็ต
เทียบกับทุก server ที่ยังใช้งานในหมวดนี้ทั้งทะเบียน ดาวนับเฉพาะเมื่อผู้ลงทะเบียนเป็นเจ้าของ repo
จากการตรวจเบื้องต้นของเรา ผ่าน 1 จาก 1 ข้อที่ตรวจได้ เรายังไม่ได้อ่านโค้ด ก่อนใส่กุญแจหรือ token ให้ดูว่า server ขอสิทธิ์อะไร และเลือกกุญแจที่ทำได้เท่าที่จำเป็น
registry ไม่ได้ระบุว่าต้องใช้กุญแจ แต่บางตัวจะขอให้ล็อกอินตอนใช้ครั้งแรก
รันบนเครื่องของคุณ โปรแกรม AI จะเปิด server ขึ้นมาเองเมื่อใช้ ข้อมูลไม่ต้องผ่านเซิร์ฟเวอร์ของผู้ทำ (ยกเว้นตัวที่ไปเรียกบริการออนไลน์ต่อ)
repo บน GitHub มีการแก้โค้ดล่าสุด – และส่งรุ่นล่าสุด (0.1.1) เข้า registry วันนี้
โปรแกรมที่รองรับ MCP เช่น Claude Desktop, Claude Code, Cursor และ VS Code ตัวนี้ต้องมี Python (uv) ในเครื่องด้วย
ในหมวดเดียวกันมี Context7, Codebase Memory, Exa
server หมวดเดียวกันจากผู้ทำคนอื่น เรียงตามดาว
อ่านการ์ด:★ ดาว GitHubiสามเสา: รีวิว · ผลตรวจ · การใช้งานiอัปเดต = วันที่ส่งรุ่นล่าสุดเข้า registryi
ส่งคู่มือการใช้ไลบรารีและเฟรมเวิร์กรุ่นล่าสุดให้ AI อ่านก่อนตอบ ช่วยให้โค้ดที่ AI เขียนไม่ใช้คำสั่งเก่าที่เลิกใช้แล้ว
Codebase knowledge graph for AI agents — 162 languages, sub-ms queries, 99% fewer tokens.
Connect AI agents to Exa for web search, content fetching, and multi-step research.
ส่วนนี้คัดจาก repo ของผู้ทำตามต้นฉบับ PopNx MCP ไม่ได้ตรวจหรือรับรองเนื้อหา ตัด HTML รูปภาพ และสคริปต์ออกแล้ว ลิงก์จะพาออกนอกเว็บ
An OT-aware authorization gateway that sits between an LLM agent and an industrial OPC UA server, applying a process-aware access policy — value ranges, rate limits, interlocks — to every call the agent makes.
Русская версия →
[MCP client / agent] ---MCP---> [otgate] ---OPC UA---> [OPC UA server]
| [policy engine + audit + shadow mode]
The same decisions as terminal output ( python examples/demo.py )
otgate is itself an MCP server. The agent connects to it as if it were an ordinary OPC UA MCP; internally otgate holds a client to the real OPC UA server. Every call is transparent to the agent, and otgate intercepts each one to apply policy and record an audit line.
It is not "you may write to this tag" but "you may write *within range X, no faster than Y over interval Z, and only while the emergency tag W is not active*".
In the OWASP Top 10 for Agentic Applications, the risk otgate targets is ASI02 — Tool Misuse & Exploitation: an agent that stays inside its granted privileges but uses a legitimate tool unsafely — parameter pollution, excessive execution, or a call that is only dangerous given the current system state.
Identity and access layers (ASI03) answer *may this agent call this tool*. They do not look at what it writes, how fast, or under which conditions. otgate is the layer that does:
| ASI02 sub-mechanism | otgate |
|---|---|
| Parameter pollution | value_range — the argument itself is checked |
| Excessive execution / scale | max_rate over rate_interval, durable across restarts |
| Unsafe given system state | interlocks — reads live guard tags before allowing |
| Unsafe composition (salami attack) | cumulative_range — bounds total drift over a window, so slicing a forbidden move into legal steps does not work |
| Recursion / call storms | max_calls over calls_interval |
| Unverifiable safety condition | fails closed — denies rather than guesses |
Per-step limits judge one write; cumulative limits judge a *series*. Without the latter an agent walks around max_rate with many small legal steps:
step 1: 50.0 -> 52.5 (drift +2.5) ALLOW
step 2: 52.5 -> 55.0 (drift +5) ALLOW step 3: 55.0 -> 57.5 (drift +7.5) ALLOW step 4: 57.5 -> 60.0 (drift +10) ALLOW step 5: 60.0 -> 62.5 (drift +12.5) DENY cumulative drift too large: 62.5 is +12.5 from 50, allowed [-10, 10]
A full mapping against all ten OWASP agentic risks — including what otgate explicitly does not cover (tool-chain manipulation, goal hijacking, memory poisoning, rogue-agent detection) — is in [docs/threat-model.md](docs/threat-model.md).
pip install -e . # core: FakeBackend, engine, MCP server
pip install -e ".[dev]" # + pytest for the test suite pip install -e ".[opcua]" # + asyncua for a real OPC UA backend
Python 3.11+.
A policy is a YAML list of per-tag rules. Any tag not listed is denied by default.
# examples/reactor_policy.yaml
Access levels: read, write, write_with_approval, deny.
Write check order (first failing check wins): tag-in-policy → access → value range → interlocks → rate of change → approval → allow.
python examples/demo.py
otgate demo — agent interacting with a reactor via the policy gateway
read temperature (PV) ALLOW read allowed -> 55.0 write setpoint = 60 degC (in range) ASK write requires human approval write setpoint = 200 degC (out of range) DENY value 200.0 is outside allowed range [40.0, 80.0] write setpoint = 60 degC while ESD active DENY interlock active: ns=2;s=Reactor.ESD == True (current ns=2;s=Reactor.ESD = True) write setpoint = 78 degC one second later DENY rate of change too high: |78.0 - 50.0| = 28 in 1s exceeds 5 per 60s
audit log
{"timestamp": "...", "action": "read", "node_id": "ns=2;s=Reactor.TIC101.PV", "value": null, "decision": "ALLOW", "reason": "read allowed", "shadow": false, "executed": true} {"timestamp": "...", "action": "write", "node_id": "ns=2;s=Reactor.TIC101.SP", "value": 60.0, "decision": "ASK", "reason": "write requires human approval", "shadow": false, "executed": false} {"timestamp": "...", "action": "write", "node_id": "ns=2;s=Reactor.TIC101.SP", "value": 200.0, "decision": "DENY", "reason": "value 200.0 is outside allowed range [40.0, 80.0]", "shadow": false, "executed": false} {"timestamp": "...", "action": "write", "node_id": "ns=2;s=Reactor.TIC101.SP", "value": 60.0, "decision": "DENY", "reason": "interlock active: ns=2;s=Reactor.ESD == True (current ns=2;s=Reactor.ESD = True)", "shadow": false, "executed": false} {"timestamp": "...", "action": "write", "node_id": "ns=2;s=Reactor.TIC101.SP", "value": 78.0, "decision": "DENY", "reason": "rate of change too high: |78.0 - 50.0| = 28 in 1s exceeds 5 per 60s", "shadow": false, "executed": false}
Published to the official MCP Registry as `io.github.alikup-ai/otgate-opcua`, and to PyPI as `otgate`.
The registry name carries
opcuabecause its search matches on the server name only and does not index
descriptions, so a bare
otgateis findable only by someone who already knows the word.
otgate exposes: read_tag, write_tag, browse, get_audit_log, and the operator approval tools list_pending, approve, deny.
otgate # console script (stdio transport)
python -m otgate.server # equivalent
Configuration is via environment variables (so the backend switches without code changes):
| Variable | Default | Meaning |
|---|---|---|
OTGATE_BACKEND | fake | fake or asyncua |
OTGATE_POLICY | examples/reactor_policy.yaml | policy YAML path |
OTGATE_AUDIT | audit.jsonl | audit log path |
OTGATE_SHADOW | *(off)* | 1/true to enable shadow mode |
OTGATE_RATE_HISTORY | *(in-memory)* | path to a JSONL file to make rate-of-change history survive restarts |
OTGATE_OPCUA_ENDPOINT | — | required when backend is asyncua |
OTGATE_AGENT_TOKEN | — | bearer token for the single-agent HTTP channel |
OTGATE_AGENTS | — | path to agents.yaml for multi-agent mode (overrides single-agent) |
OTGATE_OPERATOR_TOKEN | — | bearer token for the operator HTTP channel (must differ from every agent token) |
OTGATE_HOST / OTGATE_AGENT_PORT / OTGATE_OPERATOR_PORT | 127.0.0.1 / 8770 / 8771 | HTTP bind host and ports |
Example MCP client config (FakeBackend):
{
"mcpServers": { "otgate": { "command": "otgate", "env": { "OTGATE_BACKEND": "fake" } } } }
otgate governs what the process allows right now — ranges, rate against the live value, interlocks, drift, approval. It does not try to be the access layer underneath that, and there is a good one: IndustriAgents/OPCUA-MCP answers *may this caller touch this node at all* — read-only by default, control profiles, allowlisted targets, pinned certificates, audited control calls.
The two questions are genuinely different. A write of 40 °C to an allowlisted target satisfies every access rule and is still wrong if the tag reads 22 °C and the ramp violates a thermal limit. Access control without process limits permits that write; process limits without access control have nothing to stand on.
A visible difference in the audit trail shows the split: their acceptance criteria require records to carry profile, tool, decision and target IDs without values, which is right for an access log. otgate records the value, because "200.0 refused, outside [40, 80]" is not a sentence you can write without it.
No code changes — install the extra and point the config at your server:
pip install -e ".[opcua]"
export OTGATE_BACKEND=asyncua export OTGATE_OPCUA_ENDPOINT=opc.tcp://localhost:4840 otgate
The backend lives behind an abstract interface (otgate/backends/base.py) with two implementations — FakeBackend (in-memory simulator, no dependencies) and AsyncuaBackend (real OPC UA). asyncua is imported lazily, so the fake backend, the tests and the demo run without it.
With OTGATE_SHADOW=1, a write that the engine allows is not executed on the backend — instead the audit records a "WOULD execute" line with executed: false. This lets you run an agent and see what it *would* do to the process without any real effect.
A write_with_approval tag returns ASK. Rather than silently drop the write, otgate parks it as a pending request with a TTL and hands the agent an approval id. A human then resolves it through the operator tools:
list_pending — show parked write requests.approve — approve and execute, *after re-checking policy* against the current process state. If an interlock tripped or the value drifted out of range while the request waited, the approval is recorded but the write is blocked — an approval is intent, never a blind execute.deny — reject; the write never runs.Requests
ตัดมาแค่ช่วงต้น อ่านต่อใน repo