ramcav commited on
Commit
a07e031
·
1 Parent(s): 8635129

Added documentation

Browse files
Files changed (3) hide show
  1. .gitignore +2 -1
  2. DOCUMENTATION.md +85 -0
  3. mcp_gradio.py +1 -1
.gitignore CHANGED
@@ -1,3 +1,4 @@
1
  .env
2
  venv/
3
- __pycache__/
 
 
1
  .env
2
  venv/
3
+ __pycache__/
4
+ .DS_Store
DOCUMENTATION.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # PROMPT-TOOL 🤖
2
+
3
+ ## Overview
4
+ Prompt-tool is a Python-based utility designed to enhance and structure prompts for Large Language Models (LLMs) and AI agents, especially for coding and developer productivity tasks. It provides a Gradio web interface and an MCP server endpoint for generating context-aware, high-quality prompts, optionally leveraging available tools in the host environment.
5
+
6
+ ## Features
7
+ - **Prompt Engineering**: Generates detailed, structured prompts for LLMs, focusing on coding tasks.
8
+ - **Tool Awareness**: Can incorporate available tools (e.g., Playwright) into prompt instructions.
9
+ - **Multiple Models**: Supports different LLM models (gpt-4.1-nano, gpt-4.1-mini) for basic and advanced prompt generation.
10
+ - **Web Interface**: Gradio-based UI for interactive prompt generation.
11
+ - **MCP Server Integration**: Exposes prompt-tool as an MCP tool for programmatic access.
12
+ - **Customizable Instructions**: Uses a configurable prompt template (see `prompts/coding.txt`).
13
+
14
+ ## Installation
15
+ 1. Clone the repository and navigate to the `work/prompt-tool` directory.
16
+ 2. Install dependencies:
17
+ ```bash
18
+ pip install -r requirements.txt
19
+ ```
20
+ 3. Create a `.env` file with your OpenAI API key:
21
+ ```env
22
+ OPENAI_API_KEY=your_openai_api_key_here
23
+ ```
24
+
25
+ ## Usage
26
+ ### Gradio Web Interface
27
+ Run:
28
+ ```bash
29
+ python mcp_gradio.py
30
+ ```
31
+ - Enter your prompt, select the model (A: advanced, B: basic, N: no tooling), and specify available tools (comma-separated).
32
+ - Click "Generate" to receive an enhanced prompt.
33
+
34
+ > **Note:** When running the Gradio interface, an MCP server is also created and exposed automatically.
35
+
36
+ ### MCP Server
37
+ Run:
38
+ ```bash
39
+ python mcp_server.py
40
+ ```
41
+ This exposes the prompt-tool as an MCP tool endpoint for integration with other MCP-compatible systems.
42
+
43
+ ### Programmatic Usage
44
+ You can import and use the core functions in your own Python scripts:
45
+ ```python
46
+ from generator import prompt_tool
47
+ result = prompt_tool("Your prompt here", tool="A", tools="playwright"
48
+ ```
49
+
50
+ ## Architecture
51
+ - **generator.py**: Core logic for prompt generation, model selection, and OpenAI API interaction.
52
+ - **mcp_gradio.py**: Gradio web interface for interactive use.
53
+ - **mcp_server.py**: MCP server exposing the prompt-tool as an endpoint.
54
+ - **prompts/coding.txt**: Template and guidelines for prompt generation.
55
+ - **requirements.txt**: Python dependencies.
56
+
57
+ ## Prompt Template
58
+ The prompt-tool uses a template (`prompts/coding.txt`) that enforces best practices in prompt engineering, such as specificity, structured frameworks, tool specification, output format, and constraints.
59
+
60
+ This allows the user to use prompt-tool for whatever they want—this means that the tool can be tailored for tasks other than coding just by changing the template and a couple of lines of code.
61
+
62
+ ## Cursor integration
63
+
64
+ In order to use prompt-tool in Cursor, you need to add the following to your `.cursor/mcp.json` file:
65
+
66
+ ```json
67
+ {
68
+ "mcpServers": {
69
+ "prompt-tool": {
70
+ "url": "your_mcp_server_url"
71
+ }
72
+ }
73
+ }
74
+ ```
75
+
76
+ ## Development & Contribution
77
+ - Exclude `.env`, `venv/`, and `__pycache__/` from version control (see `.gitignore`).
78
+ - To contribute, fork the repository, create a feature branch, and submit a pull request.
79
+ - Please ensure code is well-documented and tested.
80
+
81
+ ## License
82
+ MIT License
83
+
84
+ ---
85
+ *This documentation will be updated to include images and diagrams in the future.*
mcp_gradio.py CHANGED
@@ -9,7 +9,7 @@ def main():
9
  gr.Markdown("# Prompt tool demo")
10
  prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
11
  tool = gr.Dropdown(choices=["A", "B", "N"], value="A", label="Tool", info="Select the tool type")
12
- tools = gr.Textbox(label="Tools (comma-separated)", placeholder="e.g. playwright, websearch", value="playwright")
13
  output = gr.Textbox(label="Output")
14
  btn = gr.Button("Generate")
15
 
 
9
  gr.Markdown("# Prompt tool demo")
10
  prompt = gr.Textbox(label="Prompt", placeholder="Enter your prompt here...")
11
  tool = gr.Dropdown(choices=["A", "B", "N"], value="A", label="Tool", info="Select the tool type")
12
+ tools = gr.Textbox(label="Tools (comma-separated)", placeholder="e.g. playwright, websearch")
13
  output = gr.Textbox(label="Output")
14
  btn = gr.Button("Generate")
15