This repository contains a C# Model Context Protocol (MCP) server for working with SysML v2 models and related services.
✅ Research note: The paper describing this framework has been accepted to the DESIGN 2026 conference.
The bibtex entry to cite this paper is coming soon. b
📄 License: This repository is licensed under the MIT License.
All tools are defined in mcp/Src/Tools/ModelCreationTool.cs as static methods annotated with [McpServerTool].
| Tool | Description |
|---|---|
CreateProject |
Creates a new SysML V2 project. |
GetProjects |
Lists all projects from the SysML v2 API. |
GetProjectByName |
Looks up a project by name. |
| Tool | Description |
|---|---|
GetElementsFromProjectHead |
Returns elements from the head commit of a project's default branch. Supports optional elementType and nameContains filters. |
GetAllElementsFromProjectHead |
Convenience wrapper — returns all elements with no filters applied. |
GetElementsByTypeFromProjectHead |
Returns elements filtered by a specific SysML v2 type name. |
GetPackagesFromProjectHead |
Returns only Package and LibraryPackage elements, with an optional name filter. |
GetElementByIdFromProjectHead |
Fetches a single element by GUID and returns its ownership chain. |
| Tool | Description |
|---|---|
DescribeTypeSchema |
Returns the required and optional attributes for any named SysML v2 element type. |
DescribeElementSchema |
Fetches a live element by ID and returns the same schema information scoped to that element's actual type. |
| Tool | Description |
|---|---|
CreatePackage |
Creates a package, optionally nested inside a parent package. |
CreateTopLevelPackage |
Convenience wrapper for CreatePackage at the project root. |
CreateRequirement |
Creates a RequirementUsage element, optionally nested under a parent package. |
CreateRequirementDefinition |
Creates a RequirementDefinition element with optional isAbstract flag. |
CreateUseCase |
Creates a UseCaseUsage element, optionally linked to an objective requirement. |
CreateElementOfType |
Generic tool — creates any SysML v2 element type given a JSON attributes payload. Invalid schema attributes are reported and skipped rather than causing an error. |
| Tool | Description |
|---|---|
UpdateElementAttributes |
Overwrites specific attributes on an existing element while preserving all others. Accepts a JSON object string for the attribute patch. |
AddSubjectToRequirement |
Adds a SubjectMembership + ReferenceUsage (subject parameter) to an existing requirement. |
SetRequirementDefinition |
Types a RequirementUsage against a RequirementDefinition by setting the requirementDefinition reference field. |
mcp/Src/
├── Tools/
│ └── ModelCreationTool.cs ← all MCP tool methods live here
├── Services/
│ ├── ISysMLApiService.cs ← API client interface
│ ├── SysMLApiService.cs ← HTTP implementation against localhost:9000
│ └── FactoryServices/ ← domain factories (package, requirement, use-case …)
└── Models/ ← return types used by tools
Open mcp/Src/Tools/ModelCreationTool.cs and add a public static method to the ModelCreationTools class:
[McpServerTool, Description("One-sentence description shown to the LLM.")]
public static MyReturnType MyNewTool(McpServer server, string projectName, /* … */)
{
var apiService = RequireApiService(server);
// implementation
}Key rules:
- The
[McpServerTool]and[Description("…")]attributes are mandatory — the description is what the LLM uses to decide when to call the tool. - Accept
McpServer serveras the first parameter whenever you need to call the SysML API or the metamodel factory. Retrieve services with the existingRequireApiService(server)/RequireMetaModelFactory(server)helpers. - Return a plain C# object, a primitive, or a
List<T>. The MCP framework serialises return values to JSON automatically. - Use
.GetAwaiter().GetResult()to resolve async API calls (the tool methods must be synchronous from the MCP framework's perspective).
For non-trivial creation logic, add a dedicated factory class under mcp/Src/Services/FactoryServices/ following the pattern of SysMLRequirementFactory or SysMLPackageFactory:
- Create
MySysMLXyzFactory.cswith a constructor that acceptsISysMLApiService. - Implement your logic, building
CommitRequest/DataVersionRequestpayloads and callingapiService.CommitToBranchAsync(…). - Call your factory from the tool method in
ModelCreationTool.cs.
Add a new record or class to mcp/Src/Models/ for any structured data the tool returns. Keep return types flat and JSON-serialisable so the LLM can interpret them easily.
Add a test class to csharp-mcp-example-test/ following the existing SysMLOpenApiFactoryTests.cs pattern. Run the suite with:
dotnet testThese steps use the built-in VS Code C#/.NET tooling to run and test the MCP server.
- .NET SDK (compatible with the project’s target framework)
- VS Code with the C# extension installed
- Open the repository folder in VS Code.
- In the Explorer, open
mcp/Src/Program.cs. - Press F5 to run with the debugger, or use Run > Start Debugging.
- If prompted to select an environment, choose the default .NET configuration.
- Confirm the server is running in the VS Code Debug Console/Terminal output.