The Universal Language Connector provides three main APIs:
- LSP (Language Server Protocol) - For editor integration via stdio
- HTTP REST API - For web and programmatic access
- WebSocket API - For real-time document updates
The server implements LSP 3.17 with the following capabilities:
{
textDocumentSync: "incremental",
completionProvider: {
triggerCharacters: ["#", "@", "["]
},
hoverProvider: true,
definitionProvider: true,
diagnosticProvider: true,
executeCommandProvider: {
commands: [
"convert.toMarkdown",
"convert.toHtml",
"convert.toJson"
]
}
}Notifies the server that a document has been opened.
Parameters:
{
"textDocument": {
"uri": "file:///path/to/document.md",
"languageId": "markdown",
"version": 1,
"text": "# Document content"
}
}Notifies the server of document changes.
Parameters:
{
"textDocument": {
"uri": "file:///path/to/document.md",
"version": 2
},
"contentChanges": [
{
"text": "# Updated content"
}
]
}Requests completion items at a given position.
Parameters:
{
"textDocument": {
"uri": "file:///path/to/document.md"
},
"position": {
"line": 0,
"character": 5
}
}Response:
[
{
"label": "Convert to HTML",
"kind": 1,
"detail": "Convert current document to HTML",
"command": {
"title": "Convert to HTML",
"command": "convert.toHtml",
"arguments": ["file:///path/to/document.md"]
}
}
]Provides hover information (document statistics).
Parameters:
{
"textDocument": {
"uri": "file:///path/to/document.md"
},
"position": {
"line": 0,
"character": 5
}
}Response:
{
"contents": {
"kind": "markdown",
"value": "**Document Statistics**\n\n- Lines: 10\n- Words: 50\n- Characters: 300\n- Version: 2\n- Format: markdown"
}
}Executes a conversion command.
Parameters:
{
"command": "convert.toHtml",
"arguments": ["file:///path/to/document.md"]
}Response:
{
"content": "<h1>Converted HTML</h1>",
"format": "html",
"warnings": []
}Base URL: http://localhost:8080/api
Convert document between formats.
Request:
{
"content": "# Hello World",
"from": "markdown",
"to": "html"
}Response:
{
"content": "<h1>Hello World</h1>",
"from": "markdown",
"to": "html",
"warnings": []
}Status Codes:
200 OK- Conversion successful400 Bad Request- Invalid format or content500 Internal Server Error- Conversion failed
List all documents in the server.
Response:
{
"documents": [
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"uri": "file:///path/to/document.md",
"content": "# Document content",
"language": "markdown",
"version": 1,
"created_at": "2025-11-22T12:00:00Z",
"modified_at": "2025-11-22T12:05:00Z"
}
],
"count": 1
}Get a specific document by ID.
Response:
{
"id": "550e8400-e29b-41d4-a716-446655440000",
"uri": "file:///path/to/document.md",
"content": "# Document content",
"language": "markdown",
"version": 1,
"created_at": "2025-11-22T12:00:00Z",
"modified_at": "2025-11-22T12:05:00Z"
}Status Codes:
200 OK- Document found404 Not Found- Document not found
Delete a document by ID.
Status Codes:
204 No Content- Document deleted404 Not Found- Document not found
Validate document format.
Request:
{
"content": "# Valid Markdown",
"format": "markdown"
}Response:
{
"valid": true,
"diagnostics": []
}For invalid content:
{
"valid": false,
"diagnostics": [
"Invalid JSON: unexpected token at line 1"
]
}Get server statistics.
Response:
{
"document_count": 5,
"uptime_seconds": 3600,
"version": "0.1.0"
}Health check endpoint.
Response:
{
"status": "healthy",
"version": "0.1.0"
}All errors return a standard error object:
{
"error": "Error message description"
}WebSocket URL: ws://localhost:8081
Subscribe to document updates.
Client → Server:
{
"type": "Subscribe",
"document_id": "550e8400-e29b-41d4-a716-446655440000"
}Unsubscribe from document updates.
Client → Server:
{
"type": "Unsubscribe",
"document_id": "550e8400-e29b-41d4-a716-446655440000"
}Document update notification.
Server → Client:
{
"type": "DocumentUpdated",
"document_id": "550e8400-e29b-41d4-a716-446655440000",
"content": "# Updated content",
"timestamp": "2025-11-22T12:10:00Z"
}Keep-alive messages.
Client → Server:
{
"type": "Ping"
}Server → Client:
{
"type": "Pong"
}Error notification.
Server → Client:
{
"type": "Error",
"message": "Error description"
}markdownormd- Markdownhtmlorhtm- HTMLjson- JSON
| From | To | Status | Notes |
|---|---|---|---|
| Markdown | HTML | ✅ | Full support via pulldown-cmark |
| Markdown | JSON | ✅ | Structured representation |
| HTML | Markdown | Lossy conversion | |
| HTML | JSON | ✅ | DOM structure extraction |
| JSON | Markdown | ✅ | Key-value representation |
| JSON | HTML | ✅ | Via Markdown intermediary |
Currently, the server does not implement authentication. For production use:
- Deploy behind a reverse proxy (nginx, Apache)
- Use TLS/SSL for encrypted connections
- Implement authentication at the proxy level
- Restrict access via firewall rules
No rate limiting is currently implemented. Consider adding:
- Request rate limiting at proxy level
- Connection limits for WebSocket
- Resource usage monitoring
CORS is enabled for all origins in development. For production:
- Configure specific allowed origins
- Restrict allowed methods and headers
- Implement proper preflight handling
Convert Markdown to HTML:
curl -X POST http://localhost:8080/api/convert \
-H "Content-Type: application/json" \
-d '{
"content": "# Hello World",
"from": "markdown",
"to": "html"
}'List documents:
curl http://localhost:8080/api/documentsHealth check:
curl http://localhost:8080/api/healthConvert document:
const response = await fetch('http://localhost:8080/api/convert', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
content: '# Hello World',
from: 'markdown',
to: 'html'
})
});
const result = await response.json();
console.log(result.content);WebSocket connection:
const ws = new WebSocket('ws://localhost:8081');
ws.onopen = () => {
ws.send(JSON.stringify({
type: 'Subscribe',
document_id: 'doc-123'
}));
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
console.log('Received:', message);
};- Response Time Target: <100ms for all operations
- Memory Usage: <50MB steady state
- Startup Time: <500ms
- Concurrent Connections: Supports 100+ simultaneous clients
API version is included in all responses via the version field.
Current version: 0.1.0
Future versions will maintain backward compatibility within major versions following Semantic Versioning (SemVer).