Skip to main content
Glama
vparlapalli490

ServiceNow MCP Server

create_article

Create knowledge articles in ServiceNow by providing title, content, description, category, and target knowledge base for documentation and information sharing.

Instructions

Create a new knowledge article

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
titleYesTitle of the article
textYesThe main body text for the article
short_descriptionYesShort description of the article
knowledge_baseYesThe knowledge base to create the article in
categoryYesCategory for the article
keywordsNoKeywords for search
article_typeNoThe type of articletext

Implementation Reference

  • The core handler function implementing the create_article tool. It constructs a POST request to the ServiceNow kb_knowledge table API with the provided article details and returns an ArticleResponse.
    def create_article(
        config: ServerConfig,
        auth_manager: AuthManager,
        params: CreateArticleParams,
    ) -> ArticleResponse:
        """
        Create a new knowledge article.
    
        Args:
            config: Server configuration.
            auth_manager: Authentication manager.
            params: Parameters for creating the article.
    
        Returns:
            Response with the created article details.
        """
        api_url = f"{config.api_url}/table/kb_knowledge"
    
        # Build request data
        data = {
            "short_description": params.short_description,
            "text": params.text,
            "kb_knowledge_base": params.knowledge_base,
            "kb_category": params.category,
            "article_type": params.article_type,
        }
    
        if params.title:
            data["short_description"] = params.title
        if params.keywords:
            data["keywords"] = params.keywords
    
        # Make request
        try:
            response = requests.post(
                api_url,
                json=data,
                headers=auth_manager.get_headers(),
                timeout=config.timeout,
            )
            response.raise_for_status()
    
            result = response.json().get("result", {})
    
            return ArticleResponse(
                success=True,
                message="Article created successfully",
                article_id=result.get("sys_id"),
                article_title=result.get("short_description"),
                workflow_state=result.get("workflow_state"),
            )
    
        except requests.RequestException as e:
            logger.error(f"Failed to create article: {e}")
            return ArticleResponse(
                success=False,
                message=f"Failed to create article: {str(e)}",
            )
  • Pydantic BaseModel defining the input schema/validation for the create_article tool parameters.
    class CreateArticleParams(BaseModel):
        """Parameters for creating a knowledge article."""
    
        title: str = Field(..., description="Title of the article")
        text: str = Field(..., description="The main body text for the article")
        short_description: str = Field(..., description="Short description of the article")
        knowledge_base: str = Field(..., description="The knowledge base to create the article in")
        category: str = Field(..., description="Category for the article")
        keywords: Optional[str] = Field(None, description="Keywords for search")
        article_type: Optional[str] = Field("text", description="The type of article")
  • Tool registration in the get_tool_definitions() dictionary, associating 'create_article' name with its handler function (aliased), input schema, return type hint, description, and serialization method.
    "create_article": (
        create_article_tool,
        CreateArticleParams,
        str,  # Expects JSON string
        "Create a new knowledge article",
        "json_dict",  # Tool returns Pydantic model
    ),
  • Import of the create_article handler function aliased as create_article_tool for use in tool registration.
    create_article as create_article_tool,
  • Re-export of create_article from knowledge_base.py for convenient access in the tools package.
    create_article,

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vparlapalli490/MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server