Skip to content

Commit 3176f23

Browse files
committed
update dependecies
1 parent 3a07736 commit 3176f23

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ Run OpenAPI MCP server
4949
Download latest [release JAR file](https://github.com/JavaAIDev/openapi-mcp-server/releases) and run it using `java -jar`.
5050

5151
```sh
52-
java -jar openapi-mcp-server-0.1.2-all.jar https://api.apis.guru/v2/specs/canada-holidays.ca/1.8.0/openapi.json
52+
java -jar openapi-mcp-server-0.1.2-all.jar https://api.apis.guru/v2/specs/exchangerate-api.com/4/openapi.json
5353
```
5454

5555
### Container
5656

5757
Use Docker or Podman to run the container.
5858

5959
```sh
60-
docker run -i ghcr.io/javaaidev/openapi-mcp-server https://api.apis.guru/v2/specs/canada-holidays.ca/1.8.0/openapi.json
60+
docker run -i ghcr.io/javaaidev/openapi-mcp-server https://api.apis.guru/v2/specs/exchangerate-api.com/4/openapi.json
6161
```

build.gradle.kts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ plugins {
77
group = "com.javaaidev"
88
version = "0.1.2"
99

10-
val mcpVersion = "0.6.0"
10+
val mcpVersion = "0.7.0"
1111
val slf4jVersion = "2.0.17"
1212
val logbackVersion = "1.5.18"
13-
val ktorVersion = "3.1.1"
13+
val ktorVersion = "3.3.0"
1414
val picocliVersion = "4.7.7"
15-
val swaggerParserVersion = "2.1.31"
15+
val swaggerParserVersion = "2.1.33"
1616

1717
repositories {
1818
mavenCentral()
@@ -26,6 +26,7 @@ dependencies {
2626
implementation("io.modelcontextprotocol:kotlin-sdk:${mcpVersion}")
2727
implementation("org.slf4j:slf4j-api:${slf4jVersion}")
2828
implementation("ch.qos.logback:logback-classic:${logbackVersion}")
29+
implementation("io.ktor:ktor-client-cio:${ktorVersion}")
2930
implementation("io.ktor:ktor-client-content-negotiation:${ktorVersion}")
3031
implementation("io.ktor:ktor-serialization-kotlinx-json:${ktorVersion}")
3132
implementation("io.ktor:ktor-client-logging:${ktorVersion}")

src/main/kotlin/com/javaaidev/mcp/openapi/McpTool.kt

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,17 @@ object McpToolHelper {
125125
path: String,
126126
components: Map<String, Schema<*>>?
127127
): McpTool {
128-
val name = operation.operationId ?: "${httpMethod}_$path"
128+
val name = sanitizeToolName(operation.operationId ?: "${httpMethod}_$path")
129129
val description = operation.description ?: (operation.summary ?: "")
130130
val (parameters, requiredParams) = operationParameters(operation, components)
131131
val requestBody = operationRequestBody(operation, components)
132132
val responseBody = operationResponseBody(operation, components)
133133
val toolAnnotations = if (httpMethod == "GET")
134134
ToolAnnotations(
135-
operation.operationId,
135+
name,
136136
readOnlyHint = true,
137137
destructiveHint = false,
138-
openWorldHint = false
139-
) else ToolAnnotations(operation.operationId, openWorldHint = false)
138+
) else ToolAnnotations(name)
140139
val toolInput =
141140
if (parameters?.isNotEmpty() == true && requestBody?.isNotEmpty() == true) {
142141
Tool.Input(
@@ -166,14 +165,27 @@ object McpToolHelper {
166165
Tool.Input()
167166
}
168167
val tool = Tool(
169-
name, description, toolInput, responseBody?.let { Tool.Output(it) }, toolAnnotations
168+
name,
169+
name,
170+
description,
171+
toolInput,
172+
responseBody?.let { Tool.Output(it) },
173+
toolAnnotations
170174
)
171175
val urlTemplate = serverUrl.removeSuffix("/") + "/" + path.removePrefix("/")
172176
return McpTool(tool) { request ->
173177
callApi(urlTemplate, httpMethod, request)
174178
}
175179
}
176180

181+
private fun sanitizeToolName(input: String): String {
182+
return input
183+
.replace(Regex("[^A-Za-z0-9]"), "_")
184+
.replace(Regex("_+"), "_")
185+
.trim('_')
186+
}
187+
188+
177189
private suspend fun callApi(
178190
urlTemplate: String,
179191
httpMethod: String,

0 commit comments

Comments
 (0)