-
Notifications
You must be signed in to change notification settings - Fork 114
Setting up MCP Problem Type Skeleton #1569
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
guidorc
wants to merge
8
commits into
WebFuzzing:master
Choose a base branch
from
guidorc:feature/mcp-skeleton
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ccd0ec7
Setting up MCP Problem Type Skeleton
a85ddc0
Merge branch 'master' into feature/mcp-skeleton
guidorc 22d7dd7
remove db related size from MCP individual
guidorc bc73377
Fix for resource read action id
guidorc d588c5d
feedback
f293d28
Merge branch 'master' into feature/mcp-skeleton
guidorc ff5922c
adjust resource read action parameters
d7e51b0
Merge branch 'master' into feature/mcp-skeleton
guidorc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
core/src/main/kotlin/org/evomaster/core/problem/mcp/McpAction.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| package org.evomaster.core.problem.mcp | ||
|
|
||
| import org.evomaster.core.problem.api.param.Param | ||
| import org.evomaster.core.search.action.MainAction | ||
| import org.evomaster.core.search.gene.Gene | ||
|
|
||
| abstract class McpAction( | ||
| val id: String, | ||
| parameters: MutableList<Param> | ||
| ) : MainAction(false, parameters) { | ||
|
|
||
| val actionParameters: List<Param> | ||
| get() = children as List<Param> | ||
|
|
||
|
guidorc marked this conversation as resolved.
|
||
| override fun getName(): String = id | ||
|
|
||
| override fun seeTopGenes(): List<Gene> = actionParameters.flatMap { it.seeGenes() } | ||
| } | ||
22 changes: 22 additions & 0 deletions
22
core/src/main/kotlin/org/evomaster/core/problem/mcp/McpCallResult.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package org.evomaster.core.problem.mcp | ||
|
|
||
| import org.evomaster.core.search.action.ActionResult | ||
|
|
||
| class McpCallResult : ActionResult { | ||
|
|
||
| companion object { | ||
| const val IS_ERROR = "IS_ERROR" | ||
| } | ||
|
|
||
| constructor(sourceLocalId: String) : super(sourceLocalId) | ||
|
|
||
| private constructor(other: McpCallResult) : super(other) | ||
|
|
||
| override fun copy(): McpCallResult = McpCallResult(this) | ||
|
|
||
| fun setIsError(isError: Boolean) { | ||
| addResultValue(IS_ERROR, isError.toString()) | ||
| } | ||
|
|
||
| fun getIsError(): Boolean = getResultValue(IS_ERROR)?.toBoolean() ?: false | ||
| } |
45 changes: 45 additions & 0 deletions
45
core/src/main/kotlin/org/evomaster/core/problem/mcp/McpIndividual.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| package org.evomaster.core.problem.mcp | ||
|
|
||
| import org.evomaster.core.problem.api.ApiWsIndividual | ||
| import org.evomaster.core.problem.enterprise.EnterpriseChildTypeVerifier | ||
| import org.evomaster.core.problem.enterprise.SampleType | ||
| import org.evomaster.core.search.GroupsOfChildren | ||
| import org.evomaster.core.search.Individual | ||
| import org.evomaster.core.search.StructuralElement | ||
| import org.evomaster.core.search.action.ActionComponent | ||
|
|
||
| class McpIndividual( | ||
| sampleType: SampleType, | ||
| allActions: MutableList<out ActionComponent>, | ||
| mainSize: Int = allActions.size, | ||
| sqlSize: Int = 0, | ||
| mongoSize: Int = 0, | ||
| groups: GroupsOfChildren<StructuralElement> = | ||
| getEnterpriseTopGroups(allActions, mainSize, sqlSize, mongoSize, 0, 0, 0, 0) | ||
| ) : ApiWsIndividual( | ||
| sampleType = sampleType, | ||
| children = allActions, | ||
| childTypeVerifier = EnterpriseChildTypeVerifier(McpAction::class.java), | ||
| groups = groups | ||
| ) { | ||
|
|
||
| override fun copyContent(): Individual { | ||
| return McpIndividual( | ||
| sampleType, | ||
| children.map { it.copy() }.toMutableList() as MutableList<ActionComponent>, | ||
| mainSize = groupsView()!!.sizeOfGroup(GroupsOfChildren.MAIN) | ||
| ) | ||
| } | ||
|
|
||
| fun addMcpAction(relativePosition: Int = -1, action: McpAction) { | ||
| addMainActionInEmptyEnterpriseGroup(relativePosition, action) | ||
| } | ||
|
|
||
| fun removeMcpActionAt(relativePosition: Int) { | ||
| removeMainActionGroupAt(relativePosition) | ||
| } | ||
|
|
||
| override fun seeMainExecutableActions(): List<McpAction> { | ||
| return super.seeMainExecutableActions() as List<McpAction> | ||
| } | ||
| } |
8 changes: 8 additions & 0 deletions
8
core/src/main/kotlin/org/evomaster/core/problem/mcp/McpInputParam.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package org.evomaster.core.problem.mcp | ||
|
|
||
| import org.evomaster.core.problem.api.param.Param | ||
| import org.evomaster.core.search.gene.Gene | ||
|
|
||
| class McpInputParam(name: String, gene: Gene) : Param(name, gene) { | ||
| override fun copyContent(): Param = McpInputParam(name, gene.copy()) | ||
| } |
33 changes: 33 additions & 0 deletions
33
core/src/main/kotlin/org/evomaster/core/problem/mcp/McpResourceReadAction.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package org.evomaster.core.problem.mcp | ||
|
|
||
| import org.evomaster.core.search.action.Action | ||
|
|
||
| /** | ||
| * Action to read an MCP resource. | ||
| * For direct resources (isTemplate=false), the URI is fixed and no genes are mutable. | ||
| * For template resources (isTemplate=true), one StringGene per URI template variable | ||
| * (e.g. {city} in weather:///{city}/current) is created and fuzzed independently; | ||
| * call resolvedUri() to interpolate current gene values into the template. | ||
| */ | ||
| class McpResourceReadAction( | ||
| val uriTemplate: String, | ||
| val uriParams: List<McpUriParam>, | ||
| val isTemplate: Boolean = false | ||
| ) : McpAction( | ||
| id = "resource", | ||
| parameters = uriParams.toMutableList() | ||
| ) { | ||
| override fun getName(): String = "resource:$uriTemplate" | ||
|
|
||
| fun resolvedUri(): String { | ||
| if (!isTemplate) return uriTemplate | ||
| var result = uriTemplate | ||
| uriParams.forEach { param -> | ||
| result = result.replace("{${param.name}}", param.primaryGene().getValueAsRawString()) | ||
| } | ||
| return result | ||
| } | ||
|
|
||
| override fun copyContent(): Action = | ||
| McpResourceReadAction(uriTemplate, uriParams.map { it.copy() as McpUriParam }, isTemplate) | ||
| } |
17 changes: 17 additions & 0 deletions
17
core/src/main/kotlin/org/evomaster/core/problem/mcp/McpToolCallAction.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.evomaster.core.problem.mcp | ||
|
|
||
| import org.evomaster.core.search.action.Action | ||
| import org.evomaster.core.search.gene.ObjectGene | ||
|
|
||
| class McpToolCallAction( | ||
| val toolName: String, | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. recall that, once implementation is more stable, you will need to add JavaDcos for all those classes |
||
| val inputSchema: ObjectGene, | ||
| val description: String = "" | ||
| ) : McpAction( | ||
| id = "tool:$toolName", | ||
| parameters = mutableListOf(McpInputParam("input", inputSchema)) | ||
| ) { | ||
| override fun copyContent(): Action { | ||
| return McpToolCallAction(toolName, inputSchema.copy() as ObjectGene, description) | ||
| } | ||
| } | ||
8 changes: 8 additions & 0 deletions
8
core/src/main/kotlin/org/evomaster/core/problem/mcp/McpUriParam.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| package org.evomaster.core.problem.mcp | ||
|
|
||
| import org.evomaster.core.problem.api.param.Param | ||
| import org.evomaster.core.search.gene.Gene | ||
|
|
||
| class McpUriParam(name: String, gene: Gene) : Param(name, gene) { | ||
| override fun copyContent(): Param = McpUriParam(name, gene.copy()) | ||
| } |
28 changes: 28 additions & 0 deletions
28
core/src/main/kotlin/org/evomaster/core/problem/mcp/client/HttpMcpClient.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| package org.evomaster.core.problem.mcp.client | ||
|
|
||
| class HttpMcpClient(private val baseUrl: String) : McpClient { | ||
|
|
||
| fun initialize() { | ||
| throw UnsupportedOperationException("MCP server analysis is not yet supported") | ||
| } | ||
|
|
||
| override fun listTools(): List<McpToolDefinition> { | ||
| throw UnsupportedOperationException("MCP server analysis is not yet supported") | ||
| } | ||
|
|
||
| override fun listResources(): List<McpResourceDefinition> { | ||
| throw UnsupportedOperationException("MCP server analysis is not yet supported") | ||
| } | ||
|
|
||
| override fun listResourceTemplates(): List<McpResourceTemplate> { | ||
| throw UnsupportedOperationException("MCP server analysis is not yet supported") | ||
| } | ||
|
|
||
| override fun callTool(name: String, arguments: Map<String, Any?>): McpToolResult { | ||
| throw UnsupportedOperationException("MCP server analysis is not yet supported") | ||
| } | ||
|
|
||
| override fun readResource(uri: String): McpResourceResult { | ||
| throw UnsupportedOperationException("MCP server analysis is not yet supported") | ||
| } | ||
| } |
9 changes: 9 additions & 0 deletions
9
core/src/main/kotlin/org/evomaster/core/problem/mcp/client/McpClient.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| package org.evomaster.core.problem.mcp.client | ||
|
|
||
| interface McpClient { | ||
| fun listTools(): List<McpToolDefinition> | ||
| fun listResources(): List<McpResourceDefinition> | ||
| fun listResourceTemplates(): List<McpResourceTemplate> | ||
| fun callTool(name: String, arguments: Map<String, Any?>): McpToolResult | ||
| fun readResource(uri: String): McpResourceResult | ||
| } |
36 changes: 36 additions & 0 deletions
36
core/src/main/kotlin/org/evomaster/core/problem/mcp/client/McpDTOs.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package org.evomaster.core.problem.mcp.client | ||
|
|
||
| data class McpToolDefinition( | ||
| val name: String, | ||
| val description: String = "", | ||
| val inputSchema: Map<String, Any?> = emptyMap() | ||
| ) | ||
|
|
||
| data class McpResourceDefinition( | ||
| val uri: String, | ||
| val name: String = "", | ||
| val description: String = "", | ||
| val mimeType: String? = null | ||
| ) | ||
|
|
||
| data class McpResourceTemplate( | ||
| val uriTemplate: String, | ||
| val name: String = "", | ||
| val description: String = "" | ||
| ) | ||
|
|
||
| data class McpToolResult( | ||
| val content: List<McpContent> = emptyList(), | ||
| val isError: Boolean = false | ||
| ) | ||
|
|
||
| data class McpResourceResult( | ||
| val contents: List<McpContent> = emptyList() | ||
| ) | ||
|
|
||
| data class McpContent( | ||
| val type: String, | ||
| val text: String? = null, | ||
| val uri: String? = null, | ||
| val mimeType: String? = null | ||
| ) |
17 changes: 17 additions & 0 deletions
17
core/src/main/kotlin/org/evomaster/core/problem/mcp/service/McpBlackBoxFitness.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package org.evomaster.core.problem.mcp.service | ||
|
|
||
| import org.evomaster.core.problem.mcp.McpIndividual | ||
| import org.evomaster.core.search.EvaluatedIndividual | ||
|
|
||
| class McpBlackBoxFitness : McpFitness() { | ||
|
|
||
| override fun doCalculateCoverage( | ||
| individual: McpIndividual, | ||
| targets: Set<Int>, | ||
| allTargets: Boolean, | ||
| fullyCovered: Boolean, | ||
| descriptiveIds: Boolean, | ||
| ): EvaluatedIndividual<McpIndividual>? { | ||
| throw UnsupportedOperationException("MCP server analysis is not yet supported") | ||
| } | ||
| } |
79 changes: 79 additions & 0 deletions
79
core/src/main/kotlin/org/evomaster/core/problem/mcp/service/McpBlackBoxModule.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| package org.evomaster.core.problem.mcp.service | ||
|
|
||
| import com.google.inject.AbstractModule | ||
| import com.google.inject.TypeLiteral | ||
| import org.evomaster.core.output.service.NoTestCaseWriter | ||
| import org.evomaster.core.output.service.TestCaseWriter | ||
| import org.evomaster.core.problem.enterprise.service.EnterpriseSampler | ||
| import org.evomaster.core.problem.mcp.McpIndividual | ||
| import org.evomaster.core.remote.service.RemoteController | ||
| import org.evomaster.core.remote.service.RemoteControllerImplementation | ||
| import org.evomaster.core.search.service.Archive | ||
| import org.evomaster.core.search.service.FitnessFunction | ||
| import org.evomaster.core.search.service.FlakinessDetector | ||
| import org.evomaster.core.search.service.Minimizer | ||
| import org.evomaster.core.search.service.Sampler | ||
|
|
||
| class McpBlackBoxModule( | ||
| val usingRemoteController: Boolean | ||
| ) : AbstractModule() { | ||
|
|
||
| override fun configure() { | ||
|
|
||
| bind(object : TypeLiteral<EnterpriseSampler<McpIndividual>>() {}) | ||
| .to(McpSampler::class.java) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<Sampler<McpIndividual>>() {}) | ||
| .to(McpSampler::class.java) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<Sampler<*>>() {}) | ||
| .to(McpSampler::class.java) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(McpSampler::class.java) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<FitnessFunction<McpIndividual>>() {}) | ||
| .to(McpBlackBoxFitness::class.java) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<FitnessFunction<*>>() {}) | ||
| .to(McpBlackBoxFitness::class.java) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<Archive<McpIndividual>>() {}) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<Archive<*>>() {}) | ||
| .to(object : TypeLiteral<Archive<McpIndividual>>() {}) | ||
|
|
||
| bind(Archive::class.java) | ||
| .to(object : TypeLiteral<Archive<McpIndividual>>() {}) | ||
|
|
||
| bind(object : TypeLiteral<Minimizer<McpIndividual>>() {}) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<Minimizer<*>>() {}) | ||
| .to(object : TypeLiteral<Minimizer<McpIndividual>>() {}) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<FlakinessDetector<McpIndividual>>() {}) | ||
| .asEagerSingleton() | ||
|
|
||
| bind(object : TypeLiteral<FlakinessDetector<*>>() {}) | ||
| .to(object : TypeLiteral<FlakinessDetector<McpIndividual>>() {}) | ||
| .asEagerSingleton() | ||
|
|
||
| if (usingRemoteController) { | ||
| bind(RemoteController::class.java) | ||
| .to(RemoteControllerImplementation::class.java) | ||
| .asEagerSingleton() | ||
| } | ||
|
|
||
| bind(TestCaseWriter::class.java) | ||
| .to(NoTestCaseWriter::class.java) | ||
| .asEagerSingleton() | ||
| } | ||
| } |
6 changes: 6 additions & 0 deletions
6
core/src/main/kotlin/org/evomaster/core/problem/mcp/service/McpFitness.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package org.evomaster.core.problem.mcp.service | ||
|
|
||
| import org.evomaster.core.problem.mcp.McpIndividual | ||
| import org.evomaster.core.search.service.FitnessFunction | ||
|
|
||
| abstract class McpFitness : FitnessFunction<McpIndividual>() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.