···74747575The MLF syntax is much cleaner and easier to read!
76767777+**Note:** The `"key": "tid"` field specifies that records use timestamp-based identifiers by default. You can customize this with the `@key` annotation. See [Annotations](/docs/language-guide/annotations/#key-for-records) for details.
7878+7779## Comments
78807981MLF supports three types of comments:
+24
website/content/docs/language-guide/07-xrpc.md
···241241query getPost(uri: AtUri):post | deleted;
242242```
243243244244+## Custom Encoding
245245+246246+By default, all XRPC input and output uses `application/json` encoding. You can customize this using the `@encoding` annotation:
247247+248248+**Query with custom output encoding:**
249249+```mlf
250250+@encoding("application/cbor")
251251+query getBinaryData():bytes;
252252+```
253253+254254+**Procedure with custom input encoding:**
255255+```mlf
256256+@encoding(input: "text/plain")
257257+procedure parseText(content!: string):result;
258258+```
259259+260260+**Procedure with different input/output encodings:**
261261+```mlf
262262+@encoding(input: "application/xml", output: "application/json")
263263+procedure convertXmlToJson(xml!: string):object;
264264+```
265265+266266+See [Annotations](/docs/language-guide/annotations/#encoding-for-queries-and-procedures) for more details on `@encoding`.
267267+244268## Complete Example
245269246270Here's a complete API for a forum:
···126126- `@typescript:*` - TypeScript code generator annotations
127127- `@go:*` - Go code generator annotations
128128129129+## MLF Built-in Annotations
130130+131131+MLF's lexicon generator recognizes specific annotations that affect the generated ATProto JSON lexicon:
132132+133133+### `@key` for Records
134134+135135+Controls the record key type. Defaults to `"tid"` if not specified.
136136+137137+```mlf
138138+// Use literal "self" as the record key
139139+@key("literal:self")
140140+record profile {
141141+ name!: string,
142142+}
143143+144144+// Use timestamp-based identifier (default)
145145+record post {
146146+ text!: string,
147147+}
148148+```
149149+150150+**Common key values:**
151151+- `"tid"` - Timestamp-based identifier (default)
152152+- `"literal:self"` - The record key is literally "self"
153153+- Custom values as needed for your schema
154154+155155+### `@encoding` for Queries and Procedures
156156+157157+Controls MIME type encoding for XRPC input and output. Defaults to `"application/json"` if not specified.
158158+159159+**Positional syntax** (applies to output for queries, both input/output for procedures):
160160+161161+```mlf
162162+@encoding("application/cbor")
163163+query getData(): string;
164164+165165+@encoding("application/json")
166166+procedure upload(data!: string): string;
167167+```
168168+169169+**Named syntax** (explicit control):
170170+171171+```mlf
172172+// Output only
173173+@encoding(output: "text/plain")
174174+query getText(): string;
175175+176176+// Input only
177177+@encoding(input: "application/xml")
178178+procedure parse(data!: string): result;
179179+180180+// Both input and output
181181+@encoding(input: "application/cbor", output: "application/json")
182182+procedure convert(data!: bytes): object;
183183+```
184184+185185+**Common encoding values:**
186186+- `"application/json"` - JSON (default)
187187+- `"application/cbor"` - CBOR binary format
188188+- `"text/plain"` - Plain text
189189+- `"application/xml"` - XML
190190+- `"*/*"` - Any MIME type
191191+- Custom MIME types as needed
192192+129193## Annotation Processing
130194131195Annotations are preserved in the MLF AST and can be accessed by: