Skip to content

Commit 2700751

Browse files
authored
feat: update readme (#8)
1 parent 7cd82ed commit 2700751

2 files changed

Lines changed: 46 additions & 74 deletions

File tree

README.md

Lines changed: 42 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,121 +1,93 @@
1-
# Model Context Protocol Server
1+
# Model Context Protocol Code Analysis Server
22

3-
A Kotlin server application that analyzes GitHub repositories to understand code structure and provide insights using AI
4-
models.
3+
A Kotlin server application that analyzes GitHub repositories using AI models through the Model Context Protocol (MCP).
54

65
## Features
76

87
- Clone and analyze GitHub repositories
98
- Extract code structure and relationships
10-
- Process code using context-aware models
9+
- Process code using Model Context Protocol
1110
- Generate detailed insights and summaries
12-
- RESTful API for repository analysis
11+
- Functional architecture with immutable data classes
12+
- Multiple server modes (stdio, SSE)
1313

1414
## Getting Started
1515

1616
### Prerequisites
1717

18-
- JDK 11 or higher
18+
- JDK 23 or higher
1919
- Kotlin 1.9.x
20-
- An API key for the model service (optional)
2120

2221
### Installation
2322

2423
1. Clone this repository
2524
2. Build the project using Gradle:
26-
```
25+
26+
```bash
2727
./gradlew build
2828
```
2929

3030
### Configuration
3131

3232
The application uses environment variables for configuration:
3333

34-
- `SERVER_PORT`: The port for the server (default: 8080)
34+
- `SERVER_PORT`: The port for the server (default: 3001)
3535
- `GITHUB_TOKEN`: GitHub token for API access (optional)
36-
- `WORKING_DIRECTORY`: Directory for cloning repositories (default: "temp")
37-
- `MODEL_API_URL`: URL for the model API (default: "http://localhost:11434/v1")
36+
- `WORKING_DIRECTORY`: Directory for cloning repositories (default: system temp + "/mcp-code-analysis")
37+
- `MODEL_API_URL`: URL for the model API (default: "http://localhost:11434/api")
3838
- `MODEL_API_KEY`: API key for the model service (optional)
39+
- `MODEL_NAME`: Name of the model to use (default: "llama3.2")
3940

4041
### Running the Application
4142

42-
```
43-
./gradlew run
44-
```
45-
46-
Or with custom configuration:
47-
48-
```
49-
SERVER_PORT=9090 MODEL_API_URL=https://your-model-api.com/v1 ./gradlew run
50-
```
43+
The server supports multiple modes:
5144

52-
## API Usage
45+
```bash
46+
# Default: Run as SSE server with Ktor plugin on port 3001
47+
./gradlew run
5348

54-
### Analyze a Repository
49+
# Run with standard input/output
50+
./gradlew run --args="--stdio"
5551

56-
```
57-
POST /analyze
58-
```
52+
# Run as SSE server with Ktor plugin on custom port
53+
./gradlew run --args="--sse-server-ktor 3002"
5954

60-
Request body:
55+
# Run as SSE server with plain configuration
56+
./gradlew run --args="--sse-server 3002"
6157

62-
```json
63-
{
64-
"repoUrl": "https://github.com/username/repository",
65-
"branch": "main",
66-
"analysisType": "full"
67-
}
58+
# With custom environment variables:
59+
SERVER_PORT=3002 MODEL_NAME=mistral ./gradlew run
6860
```
6961

70-
Analysis types:
62+
## Model Context Protocol
7163

72-
- `full`: Analyze all code files
73-
- `core`: Focus on core components only
74-
- `basic`: Analyze only key files
64+
This server implements the Model Context Protocol (MCP) and provides the following tool:
7565

76-
Response:
66+
- `analyze-repository` Analyzes GitHub repositories to provide code insights and structure summary.
7767

78-
```json
79-
{
80-
"id": "12345-uuid",
81-
"status": "pending"
82-
}
83-
```
68+
Required parameters:
8469

85-
### Check Analysis Status
70+
- repoUrl: GitHub repository URL (e.g., https://github.com/owner/repo)
8671

87-
```
88-
GET /status/{id}
89-
```
72+
Optional parameters:
9073

91-
Response:
92-
93-
```json
94-
{
95-
"id": "12345-uuid",
96-
"status": "completed",
97-
"summary": "This repository is a Kotlin web application...",
98-
"codeStructure": {
99-
/* Structure details */
100-
},
101-
"insights": [
102-
"The application uses MVC architecture",
103-
"Authentication is implemented using JWT"
104-
/* More insights */
105-
]
106-
}
107-
```
74+
- branch: Branch to analyze (default: main)
10875

10976
## Project Structure
11077

111-
- `src/main/kotlin/Main.kt`: Application entry point
78+
- `Main.kt`: Application entry point
11279
- `config/`: Configuration classes
113-
- `routes/`: API route definitions
80+
- `AppConfig.kt`: Immutable configuration data class
81+
- `server/`: MCP server implementation
82+
- `Server.kt`: Functional MCP server with multiple run modes
11483
- `service/`: Core services for repository analysis
115-
- `GitService`: Handles repository cloning
116-
- `CodeAnalyzer`: Analyzes code structure
117-
- `ModelContextService`: Generates insights using AI models
84+
- `GitService.kt`: Handles repository cloning
85+
- `CodeAnalyzer.kt`: Analyzes code structure
86+
- `ModelContextService.kt`: Generates insights using AI models
87+
- `RepositoryAnalysisService.kt`: Coordinates the analysis process
88+
89+
All services are implemented as functional data classes with explicit dependency injection.
11890

11991
## License
12092

121-
This project is open source and available under the MIT License.
93+
This project is open source and available under the MIT License.

src/main/kotlin/mcp/code/analysis/server/Server.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ data class Server(
7878
val transport = SseServerTransport("/message", this)
7979
val server: SdkServer = configureServer()
8080

81-
// For SSE, you can also add prompts/tools/resources if needed:
82-
// server.addTool(...), server.addPrompt(...), server.addResource(...)
81+
// For SSE, you can also add prompts/tools/resources if needed:
82+
// server.addTool(...), server.addPrompt(...), server.addResource(...)
8383

84-
servers[transport.sessionId] = server
84+
servers[transport.sessionId] = server
8585

8686
server.onClose {
8787
logger.info("Server closed")
@@ -127,7 +127,7 @@ data class Server(
127127
val server = SdkServer(implementation, serverOptions)
128128

129129
server.addTool(
130-
name = "github-code-analyzer-start",
130+
name = "analyze-repository",
131131
description = "Analyzes GitHub repositories to provide code insights and structure summary",
132132
inputSchema =
133133
Tool.Input(

0 commit comments

Comments
 (0)