create_article
Create knowledge articles in ServiceNow with title, content, categories, and search keywords to document solutions and share information across teams.
Instructions
Create a new knowledge article
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| title | Yes | Title of the article | |
| text | Yes | The main body text for the article. Field supports html formatting and wiki markup based on the article_type. HTML is the default. | |
| short_description | Yes | Short description of the article | |
| knowledge_base | Yes | The knowledge base to create the article in | |
| category | Yes | Category for the article | |
| keywords | No | Keywords for search | |
| article_type | No | The type of article. Options are 'text' or 'wiki'. text lets the text field support html formatting. wiki lets the text field support wiki markup. | html |
Implementation Reference
- The core handler function that executes the create_article tool by constructing and sending a POST request to the ServiceNow 'kb_knowledge' table API.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 parameters and validation schema for the create_article tool.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. Field supports html formatting and wiki markup based on the article_type. HTML is the default.") 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("html", description="The type of article. Options are 'text' or 'wiki'. text lets the text field support html formatting. wiki lets the text field support wiki markup.")
- src/servicenow_mcp/utils/tool_utils.py:729-735 (registration)Registers the create_article tool in the get_tool_definitions() function's dictionary, mapping the tool name to its handler, schema, description, and serialization details."create_article": ( create_article_tool, CreateArticleParams, str, # Expects JSON string "Create a new knowledge article", "json_dict", # Tool returns Pydantic model ),
- src/servicenow_mcp/tools/__init__.py:184-184 (registration)Exposes the create_article function in the __all__ list for import in the tools package."create_article",