Catalog
github/typespec-create-api-plugin

github

typespec-create-api-plugin

Generate a TypeSpec API plugin with REST operations, authentication, and Adaptive Cards for Microsoft 365 Copilot

v1.0Latest
New~999Updated Jun 26, 2026

Create TypeSpec API Plugin

Create a complete TypeSpec API plugin for Microsoft 365 Copilot that integrates with external REST APIs.

Requirements

Generate TypeSpec files with:

main.tsp - Agent Definition

import "@typespec/http";
import "@typespec/openapi3";
import "@microsoft/typespec-m365-copilot";
import "./actions.tsp";

using TypeSpec.Http;
using TypeSpec.M365.Copilot.Agents;
using TypeSpec.M365.Copilot.Actions;

@agent({
  name: "[Agent Name]",
  description: "[Description]"
})
@instructions("""
  [Instructions for using the API operations]
""")
namespace [AgentName] {
  // Reference operations from actions.tsp
  op operation1 is [APINamespace].operationName;
}

actions.tsp - API Operations

import "@typespec/http";
import "@microsoft/typespec-m365-copilot";

using TypeSpec.Http;
using TypeSpec.M365.Copilot.Actions;

@service
@actions(#{
    nameForHuman: "[API Display Name]",
    descriptionForModel: "[Model description]",
    descriptionForHuman: "[User description]"
})
@server("[API_BASE_URL]", "[API Name]")
@useAuth([AuthType]) // Optional
namespace [APINamespace] {
  
  @route("[/path]")
  @get
  @action
  op operationName(
    @path param1: string,
    @query param2?: string
  ): ResponseModel;

  model ResponseModel {
    // Response structure
  }
}

Authentication Options

Choose based on API requirements:

  1. No Authentication (Public APIs)

    // No @useAuth decorator needed
    
  2. API Key

    @useAuth(ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">)
    
  3. OAuth2

    @useAuth(OAuth2Auth<[{
      type: OAuth2FlowType.authorizationCode;
      authorizationUrl: "https://oauth.example.com/authorize";
      tokenUrl: "https://oauth.example.com/token";
      refreshUrl: "https://oauth.example.com/token";
      scopes: ["read", "write"];
    }]>)
    
  4. Registered Auth Reference

    @useAuth(Auth)
    
    @authReferenceId("registration-id-here")
    model Auth is ApiKeyAuth<ApiKeyLocation.header, "X-API-Key">
    

Function Capabilities

Confirmation Dialog

@capabilities(#{
  confirmation: #{
    type: "AdaptiveCard",
    title: "Confirm Action",
    body: """
    Are you sure you want to perform this action?
      * **Parameter**: {{ function.parameters.paramName }}
    """
  }
})

Adaptive Card Response

@card(#{
  dataPath: "$.items",
  title: "$.title",
  url: "$.link",
  file: "cards/card.json"
})

Reasoning & Response Instructions

@reasoning("""
  Consider user's context when calling this operation.
  Prioritize recent items over older ones.
""")
@responding("""
  Present results in a clear table format with columns: ID, Title, Status.
  Include a summary count at the end.
""")

Best Practices

  1. Operation Names: Use clear, action-oriented names (listProjects, createTicket)
  2. Models: Define TypeScript-like models for requests and responses
  3. HTTP Methods: Use appropriate verbs (@get, @post, @patch, @delete)
  4. Paths: Use RESTful path conventions with @route
  5. Parameters: Use @path, @query, @header, @body appropriately
  6. Descriptions: Provide clear descriptions for model understanding
  7. Confirmations: Add for destructive operations (delete, update critical data)
  8. Cards: Use for rich visual responses with multiple data items

Workflow

Ask the user:

  1. What is the API base URL and purpose?
  2. What operations are needed (CRUD operations)?
  3. What authentication method does the API use?
  4. Should confirmations be required for any operations?
  5. Do responses need Adaptive Cards?

Then generate:

  • Complete main.tsp with agent definition
  • Complete actions.tsp with API operations and models
  • Optional cards/card.json if Adaptive Cards are needed
Files1
1 files · 1.0 KB

Select a file to preview

Overall Score

82/100

Grade

B

Good

Safety

85

Quality

84

Clarity

88

Completeness

74

Summary

This skill guides agents to generate complete TypeSpec API plugins for Microsoft 365 Copilot, including agent definitions, REST operations, authentication configurations, and Adaptive Cards. It provides templated examples for main.tsp and actions.tsp files with support for multiple auth methods (API key, OAuth2, public APIs) and rich UI capabilities like confirmations and card responses.

Detected Capabilities

file writecode generationtemplate rendering

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

create typespec plugingenerate copilot apitypespec authentication setupadaptive cards for copilotrest api plugin generatorm365 copilot integration

Risk Signals

INFO

OAuth2 configuration with hardcoded authorization URL (oauth.example.com)

actions.tsp example, authentication options section
INFO

API key authentication template accepts user input for header values

Authentication Options section

Referenced Domains

External domains referenced in skill content, detected by static analysis.

oauth.example.com

Use Cases

  • Generate TypeSpec API plugin boilerplate for Copilot integration
  • Create REST operation definitions with authentication handling
  • Add Adaptive Card responses to Copilot actions
  • Configure OAuth2 or API key authentication for external APIs
  • Generate confirmation dialogs for destructive operations
  • Structure multi-operation Copilot plugins with proper TypeSpec syntax

Quality Notes

  • Excellent structure with clear sections: Requirements, Authentication Options, Function Capabilities, Best Practices, and Workflow
  • Provides four authentication patterns with concrete examples (no auth, API key, OAuth2, registered auth reference)
  • Workflow section properly guides the agent to gather requirements before generation
  • Good best practices section covering operation naming, HTTP methods, and RESTful conventions
  • TypeSpec syntax examples are well-formatted and immediately usable
  • Includes advanced features like Adaptive Cards, confirmation dialogs, reasoning directives, and response formatting
  • Clear parameter documentation with @path, @query, @header, @body markers
  • Models and response structures are well-documented with TypeScript-like syntax
Model: claude-haiku-4-5-20251001Analyzed: Jun 26, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Use github/typespec-create-api-plugin in your dev environment

Command Palette

Search for a command to run...