MCP HubMCP Hub
synaptiai

prompt-decorators

by: synaptiai

A standardized framework for enhancing how LLMs process and respond to prompts through composable decorators, featuring an official open standard specification and Python reference implementation with MCP server integration.

15created 28/02/2025
Visit
LLM
Python

πŸ“ŒOverview

Purpose: The framework aims to standardize the enhancement and transformation of prompts for Large Language Models (LLMs) through a composable annotation system.

Overview: Prompt Decorators introduces a formal and systematic method for modifying LLM behavior using simple, composable decorators. By utilizing a standardized syntax, it streamlines how developers interact with AI models, reducing complexity and enhancing consistency in prompt engineering across various platforms.

Key Features:

  • Standardized Decorator Syntax: A formal specification that defines the syntax and behavior of decorators, ensuring uniformity across LLM interactions.

  • Comprehensive Library: A wide array of over 140 pre-built decorators that facilitate various functionalities such as reasoning and output formatting.

  • Robust Implementation: A Python implementation that includes a registry for managing decorators, parameter validation, dynamic loading, and automated documentation generation.

  • Model Context Protocol (MCP) Integration: Enables functionality of prompt decorators in applications like Claude Desktop, broadening the usability of the framework.


Prompt Decorators

License Python Versions Documentation Code Style

Code Quality and Testing Documentation Publish to PyPI

Prompt Decorators is a comprehensive framework that standardizes how prompts for Large Language Models (LLMs) are enhanced, structured, and transformed. This repository contains both the official Prompt Decorators Specification and its complete Python reference implementation.

Documentation β€’ Prompt Decorators Specification

πŸ“‹ Table of Contents

  • Overview
    • What Are Prompt Decorators?
    • Key Components
    • Background & Motivation
    • Challenges in Prompt Engineering
    • Benefits of Prompt Decorators
    • Key Features
  • Implementation Status
  • Getting Started
    • Installation
    • Basic Usage
  • License
  • Contributing
  • Acknowledgments

πŸ” Overview

What Are Prompt Decorators?

Prompt Decorators introduces a standardized annotation system inspired by software design patterns that allows users to modify LLM behavior through simple, composable "decorators." By prefixing prompts with annotations like +++Reasoning, +++StepByStep, or +++OutputFormat, users can consistently control how AI models process and respond to their requests across different platforms and implementations.

This project addresses the growing complexity of AI interactions by providing:

  1. The Specification: A formal standard that defines decorator syntax, behavior, and extension mechanisms
  2. The Python Implementation: A production-ready reference implementation with comprehensive tooling
  3. MCP Integration: A Model Context Protocol server that enables prompt decorator functionality in tools like Claude Desktop

Key Components

  • πŸ“ Specification: The formal Prompt Decorators Specification (v1.0) defining the standard
  • πŸ› οΈ Core Framework: A Python implementation with registry-based decorator management
  • 🧩 140+ Decorators: A comprehensive library of pre-built decorators covering reasoning, formatting, and more
  • πŸ”Œ MCP Server: Integration with the Model Context Protocol for use with desktop AI applications
  • πŸ“š Extensive Documentation: API references, guides, and examples

Background & Motivation

As Large Language Models become increasingly integrated into workflows across industries, standardized and consistent interaction methods have become necessary. Current prompt engineering is often ad-hoc, requiring extensive documentation and causing cognitive overhead when switching systems or use cases.

Prompt Decorators provide a systematic approach to modifying AI behavior through simple, composable annotations, inspired by programming decorators. They serve as a layer of abstraction that decouples core prompts from instructions on processing and presentation.

Challenges in Prompt Engineering

Current prompt engineering suffers from several limitations:

  • Inconsistency: Instructions vary widely between users, platforms, and models
  • Verbosity: Detailed instructions consume token context that could be used for content
  • Cognitive Overhead: Users must remember or document specific prompting techniques
  • Lack of Composability: Combining different instruction paradigms is cumbersome
  • Undocumented Behavior: Expected model behavior is often implicit rather than explicit

Benefits of Prompt Decorators

Prompt Decorators solve key challenges by providing:

  • Standard syntax and behavior across LLM platforms
  • Concise annotations replacing lengthy instructions
  • Simplified prompt crafting with reusable patterns
  • Clean combination of multiple instruction paradigms
  • Explicit definitions of expected model responses

This approach makes prompt engineering more modular, reusable, and maintainable.

The framework emphasizes:

  • Standardization
  • Efficiency
  • Reusability
  • Composability
  • Explicit behavior
  • Reduced cognitive load

Key Features

  • Registry-based decorator management with metadata
  • Parameter validation and type checking
  • Decorator versioning with semantic versioning support
  • Compatibility checking for decorators
  • Documentation generation automation
  • Dynamic and runtime decorator loading and discovery

πŸ’‘ Implementation Status

The Prompt Decorators project is actively developed.

You can explore prompt decorators through the provided demos or run the MCP server implementation together with Claude Desktop.

Implemented Functionality

  • Core Decorator Registry loading from standardized JSON definitions
  • Decorator Application with parameter validation
  • Sophisticated transformation of parameters into prompt adjustments
  • Support for multiple input formats: Python functions, strings, JSON
  • Standard decorators implementation as per specification
  • Extension Framework for domain-specific decorators
  • Automated documentation generation

For detailed implementation status, see the Implementation Status document.

Roadmap

The project roadmap is detailed in the ROADMAP file.

πŸš€ Getting Started

Installation

Install from PyPI:

pip install prompt-decorators

Optional dependencies:

# For Model Context Protocol (MCP) integration
pip install "prompt-decorators[mcp]"

# For development and testing
pip install "prompt-decorators[dev,test]"

# For documentation
pip install "prompt-decorators[docs]"

# For all optional dependencies
pip install "prompt-decorators[all]"

Basic Usage

import prompt_decorators as pd

# Load available decorators
pd.load_decorator_definitions()

# Create a decorator instance
reasoning = pd.create_decorator_instance("Reasoning", depth="comprehensive")

# Apply the decorator to a prompt
prompt = "Explain the concept of prompt engineering."
decorated_prompt = reasoning.apply(prompt)

print(decorated_prompt)

For more examples, refer to the official documentation.

πŸ“ License

This project is licensed under the Apache License, Version 2.0. See the LICENSE file for more information.

🀝 Contributing

Contributions are welcome! Please read the CONTRIBUTING file for guidelines.

πŸ€– Acknowledgments

Special thanks to:

  • Mostapha Kalami Heris: For his inspiring article on Prompt Decorators
  • Synaptiai: Creators and maintainers of this framework and specification
  • Contributors: All who have contributed to this project