HNPX SDK

HNPX SDK

Enables AI-guided hierarchical fiction writing through structured XML documents. Supports step-by-step narrative expansion from book-level planning down to individual paragraphs, with custom Roo Code modes for collaborative story development.

Category
Visit Server

README

HNPX SDK

A collection of tools for HNPX - a hierarchical XML-based format for planning and writing fiction. This project introduces the HNPX format and provides tools for creating, editing, and managing HNPX documents.

Origin

LLMs can't write a good story. Well, technically they can write a good story: they'll generate thousands of words that follow narrative conventions. But they can't write your story, the specific story only you have in mind. That gap between "AI can write fiction" and "AI can't write the fiction I want" is the core of the workflow described below.

Ask an LLM to write a whole chapter, and it'll speedrun through the plot in about 300 words. Try going paragraph by paragraph, and you'll find the AI doesn't know when to stop one scene and start the next.

This led to experimenting with hierarchy: first generating a detailed chapter plan with sections, then asking the LLM to write each section individually based on that plan. This approach improved structure and word count: the chapter speedrun problem was less severe, and scene boundaries were clearer. This hierarchical method required automation, which I implemented through simple Python scripts. However, a fully automated process without guidance led the LLM to write nonsense, not at all what I wanted. The text became filled with errors, and the problem was even more pronounced when writing in Russian, where general LLMs produce noticeably poorer text quality.

The solution evolved into HNPX, a narrative planning format that structures the writing process from book-level overview down to atomic paragraphs. It allows for step-by-step expansion, maintaining context and control at each level while keeping human guidance central to the process.

To bring HNPX to life, I considered building a custom UI or VS Code extension, but that would have been too difficult: creating a whole AI agent system from scratch. Instead, I realized Roo Code already provided the perfect foundation. Its flexible mode system meant I could build an MCP server and create custom modes to use it, creating exactly the workflow HNPX required. HNPX structures the writing process so that LLMs write under human guidance at each step, transforming them from autonomous storytellers into responsive collaborators.

TL;DR: HNPX defines a structured writing workflow where LLMs write under human direction at each level, turning AI from an autonomous storyteller into a guided collaborator.

What is HNPX?

HNPX (Hierarchical Narrative Planning XML) is a structured XML format designed for planning and writing fiction. It organizes narrative content into a strict hierarchy from book-level overview down to individual paragraphs, enabling a step-by-step expansion approach that maintains context and control throughout the writing process. See docs/HNPX.md for a full specification.

The format supports both high-level planning (summaries without full text) and complete documentation (full prose ready for rendering), making it flexible for writers at any stage of their creative process.

See this file as an example of an HNPX document.

Features

  • MCP Server: Model Context Protocol server for AI agent integration
  • CLI Tools: Command-line interface for some tasks
  • Roo Code Integration: Custom modes for collaborative fiction writing
    • HNPX Editor Mode: Interactive mode for creating and editing hierarchical narrative documents
    • Bible Writer Mode: Specialized mode for creating fiction reference documents

MCP Tools

The HNPX SDK provides a comprehensive set of MCP (Model Context Protocol) tools that enable AI agents to fully manipulate HNPX documents, from creating new documents to editing individual paragraphs and restructuring the narrative hierarchy. See docs/mcp-tools.md for complete documentation.

Installation

Install the HNPX SDK:

pip install -e .
# or via uv
uv pip install -e .

Roo Code Modes Setup

To use the custom Roo Code modes for HNPX editing, place .roomodes into your project root:

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured