This guide shows you how to map security logs to the Open Cybersecurity Schema Framework (OCSF) using the MCP server’s code generation tools.
What you’ll create
Section titled “What you’ll create”A complete OCSF mapping package that:
- Identifies the appropriate OCSF event class for your logs
- Maps source fields to OCSF schema fields
- Generates TQL transformation code
- Validates the mapping against OCSF schema definitions
- Includes test cases with sample data
- Provides a ready-to-install Tenzir package
Prerequisites
Section titled “Prerequisites”- The Tenzir MCP Server installed and configured
- An MCP-aware AI agent (Claude Code, Codex, Cursor, etc.)
- Sample security log events (raw or already parsed)
Generate the mapping
Section titled “Generate the mapping”-
Provide sample log events. Give your AI agent one or more representative security events:
Prompt with Fortinet DNS query log Hey, map this log to OCSF:date=2019-05-15 time=15:05:49 logid="1501054802" type="utm" subtype="dns" eventtype="dns-response" level="notice" vd="vdom1" eventtime=1557957949740931155 policyid=1 sessionid=6887 srcip=10.1.100.22 srcport=50002 srcintf="port12" srcintfrole="undefined" dstip=172.16.100.100 dstport=53 dstintf="port11" dstintfrole="undefined" proto=17 profile="dnsfilter_fgd" srcmac="a2:e9:00:ec:40:41" xid=57945 qname="changelogs.ubuntu.com" qtype="AAAA" qtypeval=28 qclass="IN" ipaddr="2001:67c:1560:8008::11" msg="Domain is monitored" action="pass" cat=52 catdesc="Information Technology"The MCP server uses the
make_ocsf_mappingtool to analyze your data and generate a complete workflow with step-by-step instructions. This tool builds onmake_parserand calls it as the first step to ensure your logs are properly parsed before mapping them to OCSF. -
Wait for completion. In most cases you can now keep the hands off the keyboard and wait until completion. The
make_ocsf_mappingtool provides your agent with detailed guidance for:- Parsing: Builds on the parser generation tool to bootstrap the process
- Class identification: Selects the appropriate OCSF event class
- Schema analysis: Understands required and optional OCSF fields
- Field mapping: Maps source fields to OCSF schema fields
- Code generation: Generates the complete TQL transformation code
- Testing: Creates test cases to validate the mapping
Your AI agent follows these instructions to build the mapping.
-
Verify and iterate. The above log sample resulted in a new package
fortinetin your agent’s current working directory that may have the following structure:Directoryfortinet/
Directoryoperators/
Directoryocsf/
- dns.tql
- parse.tql
Directorytests/
Directoryinputs/
Directoryocsf/
- dns.txt
- parse.txt
Directoryocsf/
- dns.tql
- dns.txt
- parse.tql
- parse.txt
- package.yaml
This is a valid package including tests. The package contains both user-defined operators
fortinet::parsefor parsing the raw logs andfortinet::ocsf::mapfor mapping the parsed data to OCSF. Make sure to check the test outputs to ensure the OCSF mapping is correct.
Next steps
Section titled “Next steps”- Refine the mapping: Add enrichment, handle edge cases, or map additional
fields in
unmapped. - Install the package: Use
package::addor settenzir.package_dirsto make the mapping package available in your Tenzir node. - Add a changelog entry: Ask the agent to add a changelog entry, documenting the work.