Make Gitea URL configurable and update documentation

This commit is contained in:
Steve White 2025-01-06 16:34:57 -06:00
parent 60014c1971
commit c16f82ea38
3 changed files with 58 additions and 51 deletions

3
.env.example Normal file
View File

@ -0,0 +1,3 @@
# Gitea Configuration
GITEA_API_URL=https://gitea.r8z.us/api/v1
GITEA_TOKEN=your_token_here

100
README.md
View File

@ -1,70 +1,70 @@
# gitea-server MCP Server
# Gitea MCP Server
"An MCP server providing access to gitea.r8z.us"
An MCP server that provides tools for interacting with the Gitea API.
This is a TypeScript-based MCP server that implements a simple notes system. It demonstrates core MCP concepts by providing:
## Setup
- Resources representing text notes with URIs and metadata
- Tools for creating new notes
- Prompts for generating summaries of notes
1. Clone the repository
2. Install dependencies:
```bash
npm install
```
3. Copy the example environment file:
```bash
cp .env.example .env
```
4. Configure your environment variables in `.env`:
- `GITEA_API_URL`: Your Gitea API URL (e.g., https://gitea.example.com/api/v1)
- `GITEA_TOKEN`: Your Gitea API token
## Features
## Building
### Resources
- List and access notes via `note://` URIs
- Each note has a title, content and metadata
- Plain text mime type for simple content access
### Tools
- `create_note` - Create new text notes
- Takes title and content as required parameters
- Stores note in server state
### Prompts
- `summarize_notes` - Generate a summary of all stored notes
- Includes all note contents as embedded resources
- Returns structured prompt for LLM summarization
## Development
Install dependencies:
```bash
npm install
```
Build the server:
```bash
npm run build
```
For development with auto-rebuild:
```bash
npm run watch
```
## Available Tools
## Installation
- `list_repositories`: List repositories for the authenticated user
- `get_repository`: Get details about a specific repository
- `list_issues`: List issues in a repository
- `create_issue`: Create a new issue in a repository
- `list_pull_requests`: List pull requests in a repository
- `create_repository`: Create a new repository
- `get_contents`: Get contents of a file or directory in a repository
- `add_file_to_repo`: Add a new file to a repository
- `create_branch`: Create a new branch in a repository
To use with Claude Desktop, add the server config:
## Tool Usage Examples
On MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
On Windows: `%APPDATA%/Claude/claude_desktop_config.json`
### Adding a File to a Repository
```json
```typescript
{
"mcpServers": {
"gitea-server": {
"command": "/path/to/gitea-server/build/index.js"
}
}
"owner": "username",
"repo": "repository-name",
"path": "path/to/file.txt",
"content": "File content here", // or use file_text
"message": "Commit message",
"branch": "main" // optional
}
```
### Debugging
### Creating a Repository
Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector), which is available as a package script:
```bash
npm run inspector
```typescript
{
"name": "repository-name",
"description": "Repository description",
"private": false,
"autoInit": true
}
```
The Inspector will provide a URL to access debugging tools in your browser.
## Error Handling
The server will throw appropriate errors if:
- Required environment variables are missing
- API requests fail
- Invalid parameters are provided
- Tool names are incorrect

View File

@ -53,10 +53,14 @@ interface PullRequestArgs extends RepoArgs {
}
const GITEA_TOKEN = process.env.GITEA_TOKEN;
const GITEA_API_URL = process.env.GITEA_API_URL;
if (!GITEA_TOKEN) {
throw new Error('GITEA_TOKEN environment variable is required');
}
const GITEA_API_URL = 'https://gitea.r8z.us/api/v1';
if (!GITEA_API_URL) {
throw new Error('GITEA_API_URL environment variable is required');
}
class GiteaServer {
private server: Server;