@@ -36,7 +36,7 @@ func registerTools(server *mcp.Server, svc *service.CardService, skillsDir strin
3636 registerCreateProject (server , svc )
3737 registerUpdateProject (server , svc )
3838 registerDeleteProject (server , svc )
39- registerStartWorkflow (server , svc )
39+ registerStartWorkflow (server , svc , skillsDir )
4040 registerGetSkill (server , svc , skillsDir )
4141 registerReportPush (server , svc )
4242 registerIncrementReviewAttempts (server , svc )
@@ -58,10 +58,12 @@ func resolveProject(ctx context.Context, svc *service.CardService, project, card
5858
5959// --- Input/Output types ---
6060
61- type listProjectsInput struct {}
62- type listProjectsOutput struct {
63- Projects []board.ProjectConfig `json:"projects"`
64- }
61+ type (
62+ listProjectsInput struct {}
63+ listProjectsOutput struct {
64+ Projects []board.ProjectConfig `json:"projects"`
65+ }
66+ )
6567
6668type listCardsInput struct {
6769 Project string `json:"project" jsonschema:"required,project name"`
@@ -845,42 +847,52 @@ func registerDeleteProject(server *mcp.Server, svc *service.CardService) {
845847// --- start_workflow tool ---
846848
847849type startWorkflowInput struct {
848- CardID string `json:"card_id" jsonschema:"required,card ID to start the workflow for (e.g. ALPHA-001)"`
850+ CardID string `json:"card_id" jsonschema:"required,card ID to start the workflow for (e.g. ALPHA-001)"`
851+ IncludePreamble * bool `json:"include_preamble,omitempty" jsonschema:"include workflow rules preamble (default true, pass false to skip on subsequent calls when you already have it)"`
849852}
850853type startWorkflowOutput struct {
851- CardID string `json:"card_id "`
852- Workflow string `json:"workflow "`
853- Prompt string `json:"prompt "`
854- Instruction string `json:"instruction "`
854+ SkillName string `json:"skill_name "`
855+ Model string `json:"model,omitempty "`
856+ Content string `json:"content "`
857+ Inline bool `json:"inline,omitempty "`
855858}
856859
857- func registerStartWorkflow (server * mcp.Server , svc * service.CardService ) {
860+ func registerStartWorkflow (server * mcp.Server , svc * service.CardService , skillsDir string ) {
858861 mcp .AddTool (server , & mcp.Tool {
859862 Name : "start_workflow" ,
860863 Description : "Start the workflow for a card. Call this when a user asks to " +
861- "'start workflow', 'plan', 'work on', 'begin', or 'run' a card. " +
862- "Inspects the card's autonomous flag and returns which workflow prompt to invoke: " +
863- "run-autonomous (for autonomous cards) or create-plan (for human-in-the-loop cards)." ,
864+ "'start workflow', 'start', 'plan', 'work on', 'begin', or 'run' a card. " +
865+ "Inspects the card's autonomous flag and returns the full workflow skill content: " +
866+ "run-autonomous (for autonomous cards) or create-plan (for human-in-the-loop cards). " +
867+ "Always returns inline: true — execute the content directly." ,
864868 }, func (ctx context.Context , _ * mcp.CallToolRequest , input startWorkflowInput ) (* mcp.CallToolResult , startWorkflowOutput , error ) {
865869 card , _ , err := findCard (ctx , svc , input .CardID )
866870 if err != nil {
867871 return nil , startWorkflowOutput {}, fmt .Errorf ("start workflow: %w" , err )
868872 }
869873
874+ skill := "create-plan"
870875 if card .Autonomous {
871- return nil , startWorkflowOutput {
872- CardID : input .CardID ,
873- Workflow : "run-autonomous" ,
874- Prompt : "/contextmatrix:run-autonomous " + input .CardID ,
875- Instruction : "This card has autonomous mode enabled. Run the prompt shown above to drive it through the full lifecycle without human approval gates." ,
876- }, nil
876+ skill = "run-autonomous"
877+ }
878+
879+ includePreamble := input .IncludePreamble == nil || * input .IncludePreamble
880+ result , err := buildSkillContent (ctx , svc , skillsDir , skill , skillArgs {
881+ CardID : input .CardID ,
882+ }, includePreamble )
883+ if err != nil {
884+ return nil , startWorkflowOutput {}, fmt .Errorf ("start workflow: %w" , err )
877885 }
886+ content := stripAgentConfig (result .Content )
887+
888+ // start_workflow always returns inline content — both create-plan
889+ // and run-autonomous are executed directly by the orchestrator.
890+ content = buildInlineExecutionPrompt (content , input .CardID , skill )
878891
879892 return nil , startWorkflowOutput {
880- CardID : input .CardID ,
881- Workflow : "create-plan" ,
882- Prompt : "/contextmatrix:create-plan " + input .CardID ,
883- Instruction : "This card uses the human-in-the-loop workflow. Run the prompt shown above to start planning with approval gates." ,
893+ SkillName : skill ,
894+ Content : content ,
895+ Inline : true ,
884896 }, nil
885897 })
886898}
0 commit comments