Skip to content

Commit ed71b8c

Browse files
authored
feature: extract code analyzer to its own class (#19)
1 parent e6442e9 commit ed71b8c

File tree

14 files changed

+186
-1036
lines changed

14 files changed

+186
-1036
lines changed

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ A Kotlin server application that analyzes GitHub repositories using AI models th
1515
### Prerequisites
1616

1717
- JDK 23 or higher
18-
- Kotlin 1.9.x
19-
- Gradle 8.14 or higher
18+
- Kotlin 2.2.x
19+
- Gradle 9.0 or higher
2020
- [Ollama](https://github.com/ollama/ollama) 3.2 or higher (for model API)
2121
- [MCP Inspector](https://github.com/modelcontextprotocol/inspector) (for model context protocol)
2222

@@ -32,13 +32,13 @@ A Kotlin server application that analyzes GitHub repositories using AI models th
3232
3. Start Ollama server:
3333

3434
```bash
35-
ollama run llama3.2
35+
ollama run llama3.2:latest
3636
```
3737

3838
4. Start the MCP Inspector:
3939

4040
```bash
41-
npx @modelcontextprotocol/inspector
41+
export DANGEROUSLY_OMIT_AUTH=true; npx @modelcontextprotocol/inspector@0.16.2
4242
```
4343

4444
5. You can access the MCP Inspector at `http://127.0.0.1:6274/` and configure the `Arguments` to start the server:
@@ -114,10 +114,11 @@ Optional parameters:
114114
- `config/`: Configuration classes
115115
- `AppConfig.kt`: Immutable configuration data class
116116
- `server/`: MCP server implementation
117-
- `Server.kt`: Functional MCP server with multiple run modes
117+
- `Mcp.kt`: Functional MCP server with multiple run modes
118+
- `processor/`: MCP server implementation
119+
- `CodeAnalyzer.kt`: Analyzes code structure
118120
- `service/`: Core services for repository analysis
119121
- `GitService.kt`: Handles repository cloning
120-
- `CodeAnalyzer.kt`: Analyzes code structure
121122
- `ModelContextService.kt`: Generates insights using AI models
122123
- `RepositoryAnalysisService.kt`: Coordinates the analysis process
123124

build.gradle.kts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ plugins {
77
`maven-publish`
88
signing
99
jacoco
10-
kotlin("jvm") version "2.1.0"
11-
kotlin("plugin.serialization") version "2.1.0"
10+
kotlin("jvm") version "2.2.10"
11+
kotlin("plugin.serialization") version "2.2.10"
1212
id("com.diffplug.spotless") version "7.0.3"
13-
id("io.kotest.multiplatform") version "5.0.2"
13+
id("io.kotest.multiplatform") version "5.9.1"
1414
id("org.jreleaser") version "1.17.0"
1515
id("pl.allegro.tech.build.axion-release") version "1.18.7"
1616
}
@@ -27,9 +27,10 @@ version = rootProject.scmVersion.version
2727
description = "MCP Server for GitHub Code Repositories Analysis"
2828

2929
dependencies {
30-
val ktorVersion = "3.0.2"
30+
val ktorVersion = "3.2.0"
3131
val coroutinesVersion = "1.10.2"
3232
val kotestVersion = "5.9.1"
33+
val mcpKotlinSdk = "0.6.0"
3334

3435
// Kotlin standard library
3536
implementation(kotlin("stdlib"))
@@ -45,7 +46,7 @@ dependencies {
4546
implementation("io.ktor:ktor-serialization-kotlinx-json:$ktorVersion")
4647

4748
// MCP SDK
48-
implementation("io.modelcontextprotocol:kotlin-sdk:0.5.0")
49+
implementation("io.modelcontextprotocol:kotlin-sdk:$mcpKotlinSdk")
4950

5051
// Logging
5152
implementation("ch.qos.logback:logback-classic:1.5.18")

gradle/wrapper/gradle-wrapper.jar

122 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-9.0.0-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import org.gradle.kotlin.dsl.maven
22

3-
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" }
3+
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" }
44

55
rootProject.name = "mcp-github-code-analyzer"
66

src/main/kotlin/Main.kt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import java.io.IOException
22
import java.nio.file.Path
33
import java.nio.file.Paths
44
import mcp.code.analysis.config.AppConfig
5-
import mcp.code.analysis.server.Server
5+
import mcp.code.analysis.server.Mcp
66
import org.slf4j.Logger
77
import org.slf4j.LoggerFactory
88

@@ -88,7 +88,7 @@ fun runApplication(args: Array<String>): Result<Unit> = runCatching {
8888
logger.error("Failed to create necessary directories, check previous errors")
8989
throw IOException("Failed to create one or more required directories")
9090
}
91-
executeCommand(command, Server())
91+
executeCommand(command, Mcp())
9292
}
9393

9494
/**
@@ -160,13 +160,13 @@ fun createDirectoryWithFullPath(path: Path): Result<Pair<Path, Boolean>> = runCa
160160
* @param server The Server instance to use for execution.
161161
* @throws IllegalArgumentException If the command type is UNKNOWN.
162162
*/
163-
fun executeCommand(command: AppCommand, server: Server) {
163+
fun executeCommand(command: AppCommand, server: Mcp) {
164164
val logger = LoggerFactory.getLogger("Main")
165165

166166
when (command.type) {
167-
CommandType.STDIO -> server.runMcpServerUsingStdio()
168-
CommandType.SSE_KTOR -> server.runSseMcpServerUsingKtorPlugin(command.port)
169-
CommandType.SSE_PLAIN -> server.runSseMcpServerWithPlainConfiguration(command.port)
167+
CommandType.STDIO -> server.runUsingStdio()
168+
CommandType.SSE_KTOR -> server.runSseUsingKtorPlugin(command.port)
169+
CommandType.SSE_PLAIN -> server.runSseWithPlainConfiguration(command.port)
170170
CommandType.UNKNOWN -> throw IllegalArgumentException("Unknown command: ${command.type}")
171171
}.also { logger.info("Executed command: ${command.type}") }
172172
}

0 commit comments

Comments
 (0)