prompt-logger

alexniklev/prompt-logger

3.1

If you are the rightful owner of prompt-logger and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

MCP server that saves prompts to a repository.

Prompt Logger — MCP Server

A minimal Model Context Protocol (MCP) server that lets MCP‑aware clients (e.g. VS Code Copilot Chat with MCP support) persist prompts into a Git repository as Markdown files (with YAML frontmatter). Each save creates a new file, commits it, and pushes to the configured remote.

Current scope: a single tool (SavePrompt). Retrieval / listing are stubs or future roadmap items.

Why

Capture interesting prompts / conversations as immutable, versioned artifacts in a normal Git workflow so they can be:

  • Audited (history, diffs)
  • Reviewed and tagged
  • Reused across sessions / team members
  • Processed by other automation (indexing, analytics, embedding pipelines)

Features (Implemented Now)

  • Save a prompt into a Git repository (local + push)
  • Automatic filename generation with timestamp + slug
  • YAML frontmatter with created_at (UTC ISO 8601)
  • Minimal, dependency‑light code path
  • Runs over MCP stdio transport

Roadmap / Planned

  • Add metadata injection (author, tags, model, session id)
  • Optional delayed push (toggle immediate push vs local only)
  • List / search prompts tool
  • Get single prompt tool (actual file read)
  • Size limits (MAX_PROMPT_SIZE)
  • Git author identity env vars
  • Optional branch targeting
  • Robust error surface (JSON structured tool output)

File Layout

Saved prompt example (generated by the current implementation):

---
created_at: 2025-01-05T14:22:33.1234567Z
---

What is the weather in Sofia tomorrow?

Filename Format

prompt-YYYYMMDD_HHmms-<optional-slug>.md

  • YYYYMMDD_HHmms = UTC timestamp (sortable, millisecond precision)
  • <optional-slug> = first non-empty line of the prompt, lower‑cased, trimmed, sanitized (alphanumerics + - / _, max 40 chars)
  • Example: prompt-20250105_142233512-what-is-the-weather-in-sofia.md

Tools Exposed (MCP)

ToolDescriptionParameters
SavePromptSaves a prompt text to the repo, commits, pushes. Returns path + commit info (commit SHA placeholder today).prompt (string, required)
GetPromptPlaceholder (returns a stub string).prompt (string)

SavePrompt Return Shape (current string form)

Saved: prompts/prompt-20250105_142233512-example.md
Commit: committed
Pushed: True

If it fails:

Error: <reason>

(Planned: return structured JSON via the tool API.)

Environment Variables (Currently Supported)

VariablePurposeDefault
REPO_PATHPath to an existing Git working copy to write into.Current working directory
PROMPTS_FOLDERDirectory (relative to repo root) to store prompt files.prompts

Other variables mentioned in the roadmap (author identity, push control, size limits) are not implemented yet and intentionally omitted here.

Git Remote / Auth

The code assumes the repo at REPO_PATH already has a configured remote and appropriate credentials available to git (SSH agent, credential manager, etc.). It simply runs:

git pull
git add <file>
git commit -m "Add prompt <filename>"
git push

Quick Start

  1. Prepare a Git repo (existing or new):
    git init prompt-archive
    cd prompt-archive
    git remote add origin <your-remote>
    git pull origin main || true
    
  2. Clone this project (or add as a tool service in your workspace).
  3. (Optional) set environment variables:
    set REPO_PATH=path\to\prompt-archive
    set PROMPTS_FOLDER=prompts
    
  4. Run the MCP server:
    dotnet run --project src/PromptLoggerMcpServer
    
  5. Configure .vscode/mcp.json (VS Code with MCP support):
    {
      "servers": {
        "PromptLoggerMcpServer": {
          "type": "stdio",
          "command": "dotnet",
          "args": [
            "run",
            "--project",
            "src/PromptLoggerMcpServer"
          ],
          "env": {
            "REPO_PATH": "C:/dev/prompt-archive"
          }
        }
      }
    }
    
  6. In Copilot Chat (or another MCP client), invoke the tool:
    /tool PromptLoggerMcpServer.SavePrompt prompt="What is the weather in Sofia tomorrow?"
    
  7. Inspect the repo:
    git log --oneline -1
    ls prompts/
    

Error Handling

Typical failure causes:

  • REPO_PATH not a Git repo (missing .git directory)
  • Empty prompt text
  • Git command failure (network / auth / non-fast-forward)

Errors are returned as a simple string beginning with Error:.

Limitations / Caveats

  • Always pushes immediately (cannot opt out yet)
  • No structured JSON response
  • No deduplication / hashing (each call = new file)
  • No metadata enrichment beyond timestamp
  • GetPrompt is a stub
  • No concurrency coordination (simultaneous writes may race but filenames use millisecond precision; still possible under extreme parallelism)

Release Notes

1.0.0 (Initial)

  • Initial MCP server scaffolding
  • SavePrompt tool with git pull/add/commit/push workflow
  • Timestamp + slug filename strategy
  • YAML frontmatter with created_at
  • Basic error messages
  • Stub GetPrompt tool

Development

dotnet build
dotnet run --project src/PromptLoggerMcpServer

Contributing

Issues / PRs welcome. Focus areas: metadata, retrieval tooling, structured output, tests.

License

MIT (see LICENSE if present; otherwise add one before public distribution).

References


Future improvements will be tracked in the issue tracker. Suggestions welcome.