Skip to content

Commit d418284

Browse files
authored
fix: release task (#21)
1 parent d49db61 commit d418284

File tree

4 files changed

+166
-18
lines changed

4 files changed

+166
-18
lines changed

build.gradle.kts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@ plugins {
1818
scmVersion {
1919
unshallowRepoOnCI.set(true)
2020
tag { prefix.set("v") }
21+
versionCreator("versionWithBranch")
22+
branchVersionCreator.set(mapOf("main" to "simple"))
23+
versionIncrementer("incrementMinor")
24+
branchVersionIncrementer.set(mapOf("feature/.*" to "incrementMinor", "bugfix/.*" to "incrementPatch"))
2125
}
2226

2327
group = "io.github.eschizoid"
24-
2528
version = rootProject.scmVersion.version
26-
2729
description = "MCP Server for GitHub Code Repositories Analysis"
2830

2931
dependencies {
@@ -78,15 +80,15 @@ application { mainClass.set("MainKt") }
7880

7981
tasks.jar {
8082
manifest { attributes["Main-Class"] = "MainKt" }
81-
8283
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
83-
8484
exclude("META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA")
85-
8685
from(configurations.runtimeClasspath.get().map { if (it.isDirectory) it else zipTree(it) })
8786
}
8887

89-
tasks.test { useJUnitPlatform() }
88+
tasks.test {
89+
useJUnitPlatform()
90+
jvmArgs("-Dnet.bytebuddy.experimental=true")
91+
}
9092

9193
tasks.jacocoTestReport {
9294
reports {
@@ -99,7 +101,23 @@ tasks.jacocoTestReport {
99101
java {
100102
withSourcesJar()
101103
withJavadocJar()
102-
toolchain { languageVersion = JavaLanguageVersion.of(23) }
104+
toolchain { languageVersion = JavaLanguageVersion.of(24) }
105+
}
106+
107+
repositories {
108+
mavenCentral()
109+
maven("https://maven.pkg.jetbrains.space/public/p/kotlin-mcp-sdk/sdk")
110+
maven {
111+
credentials {
112+
username =
113+
System.getenv("JRELEASER_MAVENCENTRAL_SONATYPE_USERNAME")
114+
?: project.properties["mavencentralSonatypeUsername"]?.toString()
115+
password =
116+
System.getenv("JRELEASER_MAVENCENTRAL_SONATYPE_PASSWORD")
117+
?: project.properties["mavencentralSonatypePassword"]?.toString()
118+
}
119+
url = uri("https://central.sonatype.com/")
120+
}
103121
}
104122

105123
spotless {
@@ -196,6 +214,7 @@ jreleaser {
196214
stagingRepository("build/staging-deploy")
197215
enabled.set(true)
198216
sign.set(false)
217+
maxRetries.set(180)
199218
}
200219
}
201220
}

settings.gradle.kts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
import org.gradle.kotlin.dsl.maven
2-
31
plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0" }
42

53
rootProject.name = "mcp-github-code-analyzer"
6-
7-
dependencyResolutionManagement {
8-
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
9-
repositories {
10-
mavenCentral()
11-
maven("https://maven.pkg.jetbrains.space/public/p/kotlin-mcp-sdk/sdk")
12-
}
13-
}

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

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import io.modelcontextprotocol.kotlin.sdk.server.ServerOptions
1616
import io.modelcontextprotocol.kotlin.sdk.server.SseServerTransport
1717
import io.modelcontextprotocol.kotlin.sdk.server.StdioServerTransport
1818
import io.modelcontextprotocol.kotlin.sdk.server.mcp
19+
import java.util.Locale.getDefault
1920
import kotlinx.coroutines.*
2021
import kotlinx.io.asSink
2122
import kotlinx.io.asSource
@@ -240,7 +241,134 @@ class Mcp(
240241
}
241242
}
242243

243-
logger.info("MCP server configured successfully with 1 tool")
244+
server.addPrompt(
245+
name = "analyze-codebase",
246+
description = "Generate a comprehensive analysis prompt for a codebase",
247+
arguments =
248+
listOf(
249+
PromptArgument(
250+
name = "focus",
251+
description = "What aspect to focus on (architecture, security, performance, etc.)",
252+
required = false,
253+
),
254+
PromptArgument(
255+
name = "language",
256+
description = "Primary programming language of the codebase",
257+
required = false,
258+
),
259+
),
260+
) { request ->
261+
val focus = request.arguments?.get("focus") ?: "general architecture"
262+
val language = request.arguments?.get("language") ?: "any language"
263+
264+
val promptText =
265+
"""
266+
Please analyze this codebase with a focus on ${focus}.
267+
268+
Primary language: $language
269+
270+
Please provide:
271+
1. Overall architecture and design patterns
272+
2. Code quality and maintainability assessment
273+
3. Potential security concerns
274+
4. Performance considerations
275+
5. Recommendations for improvements
276+
277+
Focus particularly on $focus aspects of the code.
278+
"""
279+
.trimIndent()
280+
281+
GetPromptResult(
282+
description = "Codebase analysis prompt focusing on $focus",
283+
messages = listOf(PromptMessage(role = Role.user, content = TextContent(promptText))),
284+
)
285+
}
286+
287+
server.addPrompt(
288+
name = "code-review",
289+
description = "Generate a code review prompt template",
290+
arguments =
291+
listOf(
292+
PromptArgument(
293+
name = "type",
294+
description = "Type of review (security, performance, style, etc.)",
295+
required = false,
296+
)
297+
),
298+
) { request ->
299+
val reviewType = request.arguments?.get("type") ?: "comprehensive"
300+
301+
val promptText =
302+
"""
303+
Please perform a $reviewType code review of the following code.
304+
305+
Review criteria:
306+
- Code clarity and readability
307+
- Best practices adherence
308+
- Potential bugs or issues
309+
- Performance implications
310+
- Security considerations
311+
- Maintainability
312+
313+
Please provide specific feedback with examples and suggestions for improvement.
314+
"""
315+
.trimIndent()
316+
317+
GetPromptResult(
318+
description =
319+
"${reviewType.replaceFirstChar { if (it.isLowerCase()) it.titlecase(getDefault()) else it.toString() }} code review template",
320+
messages = listOf(PromptMessage(role = Role.user, content = TextContent(promptText))),
321+
)
322+
}
323+
324+
server.addResource(
325+
uri = "repo://analysis-results",
326+
name = "Repository Analysis Results",
327+
description = "Latest repository analysis results",
328+
mimeType = "application/json",
329+
) {
330+
// Return cached analysis results or a placeholder
331+
ReadResourceResult(
332+
contents =
333+
listOf(
334+
TextResourceContents(
335+
uri = "repo://analysis-results",
336+
mimeType = "application/json",
337+
text = """{"message": "No analysis results available yet. Run analyze-repository tool first."}""",
338+
)
339+
)
340+
)
341+
}
342+
343+
server.addResource(
344+
uri = "repo://metrics",
345+
name = "Repository Metrics",
346+
description = "Code metrics and statistics",
347+
mimeType = "application/json",
348+
) {
349+
ReadResourceResult(
350+
contents =
351+
listOf(
352+
TextResourceContents(
353+
uri = "repo://metrics",
354+
mimeType = "application/json",
355+
text =
356+
"""
357+
{
358+
"totalFiles": 0,
359+
"linesOfCode": 0,
360+
"languages": [],
361+
"lastAnalyzed": null,
362+
"complexity": "unknown"
363+
}
364+
"""
365+
.trimIndent(),
366+
)
367+
)
368+
)
369+
}
370+
371+
logger.info("MCP server configured successfully with 1 tool, 2 prompts, and 2 resources")
244372
return server
245373
}
246374
}

src/test/kotlin/mcp/code/analysis/server/McpTest.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class McpTest {
1919
private lateinit var serverUnderTest: Mcp
2020

2121
private val toolHandlerSlot = slot<suspend (CallToolRequest) -> CallToolResult>()
22+
private val resourceHandlerSlot = slot<suspend (String) -> String>()
2223

2324
@BeforeEach
2425
fun setUp() {
@@ -31,6 +32,16 @@ class McpTest {
3132
anyConstructed<SdkServer>()
3233
.addTool(name = any(), description = any(), inputSchema = any(), handler = capture(toolHandlerSlot))
3334
} returns Unit
35+
36+
every {
37+
anyConstructed<SdkServer>()
38+
.addPrompt(name = any<String>(), description = any(), arguments = any(), promptProvider = any())
39+
} returns Unit
40+
41+
every {
42+
anyConstructed<SdkServer>()
43+
.addResource(name = any<String>(), description = any(), uri = any(), mimeType = any(), readHandler = any())
44+
} returns Unit
3445
}
3546

3647
@AfterEach

0 commit comments

Comments
 (0)